howler.js

Repeat audio on Chrome/Firefox mobile when phone is off

百般思念 提交于 2020-01-25 07:04:09
问题 I wrote a small language learning app for my own use which plays audio recordings with howlerjs. The audio is played in a loop, when the end is reached, it just restarts until the user intervenes. To the Problem : When I turn off my phone (standby) the audio file still plays - like it should - but is not restarted ones the end is reached. Is there a JavaScript trick I can use to restart it even when my phone is off? Or can I change a setting in Chrome/Firefox to stop Chrome/Firefox from

使用Javascript播放音频?

本小妞迷上赌 提交于 2020-01-06 18:36:51
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 我正在用HTML5和Javascript制作游戏。 如何通过Javascript播放游戏音频? #1楼 如果您不想弄乱HTML元素: var audio = new Audio('audio_file.mp3'); audio.play(); var audio = new Audio('https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3'); audio.play(); 这使用 HTMLAudioElement 接口,该接口播放音频的方式与 <audio> 元素相同 。 如果需要更多功能,我使用了 howler.js 库,发现它简单实用。 <script src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.1.1/howler.min.js"></script> <script> var sound = new Howl({ src: ['https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3'], volume: 0.5, onend: function () {

Howler.js - referencing and triggering files from an array/for-loop

北战南征 提交于 2019-12-25 04:50:33
问题 I'm trying to use an array and for-loop to index and name some Howls and Howl trigger buttons. I've referenced this question for what I'm trying to achieve: Howler - Random sound The difference with mine is that it's without the random aspect plus I've added some method calls. I'm adding the buttons used to trigger the Howls into the loop and that's where it seems to be failing - namely when the buttons are clicked. Console reports the following when either button is clicked: Uncaught

Trying to import an npm module (Howler) in Angular 2 app

前提是你 提交于 2019-12-22 11:28:59
问题 I am trying to import Howler inside my angular 2 app, but it does not have a typings file. I am confused and have been searching for the answer, but cannot find anything. How do I go about importing "howler" inside my component without a typings file? 回答1: Try DefinitelyTyped typings definition for howler. Here is the repo on GitHub where you can find howler.d.ts Here is the npm package info TypeScript v2 use following command to install npm install --save @types/howler If you have any

Javascript and Howler.js - how to choose a random sound?

岁酱吖の 提交于 2019-12-14 03:42:43
问题 I am rather new to javascript and trying to have random selected sounds playing on mousemove. I can't get to work and would appreciate help. I am using howler.min.js to control the sound so does not wait for the sound to play to end before it plays the next sound. Here is the code: var soundObjects = []; var lastSoundTime = Date.now(); c.addEventListener("mousemove",function(evt){ var mx = evt.clientX - this.offsetLeft; var my = evt.clientY - this.offsetTop; //console.log("clicked at x:" + mx

Howler.js doesn't recognize src path to audio file

一个人想着一个人 提交于 2019-12-12 01:25:59
问题 After successfully playing an audio file with the HTML5 built-in audio tag, I'm trying to switch to use howler.js instead. I've verified that howler.js is properly installed and that the method which creates/plays my song is being called with a console.log, but I'm confused as to why the path isn't recognized here: new Howl({src: ['../music/lofi.mp3']}) while the same path works just fine here: <audio autoplay> <source src="../music/lofi.mp3" type="audio/mpeg" id="track"/> </audio> export

Howler JS 2.0 - sound is not playing on cordova, android, device

隐身守侯 提交于 2019-12-11 03:20:50
问题 i'm trying to play sound in mobile hybrid app (cordova, ionic, howlerJS v 2), https://github.com/goldfire/howler.js/tree/2.0 By this way: $scope.playSelectedItem = function(index) { try { var fileName = $scope.selectedSounds[index].file; var filePath = "sounds/" +fileName+".mp3"; console.log(filePath); var sound = new Howl({ src: [filePath] }); sound.play(); } catch(e) { $scope.showAlert(); } }; In Chrome mobile emulator everything works fine, but on device is sound not playing. I checked app

Avoid stopping background audio for howler.js sprite playback on iOS

房东的猫 提交于 2019-12-11 03:02:42
问题 I'm making a little browser game as a study project, with howler.js 2.0 handling the sound effects. When I play the game on iOS and I'm listening to music (say, in the music player app), the game sound effects will stop the background audio. Actually, I believe all background audio stops upon load of the game. Is there any way to prevent this and keep the background audio going? I'd prefer to avoid audio ducking as well, but could live with that if it's the only option. The game is here: http

Connect analyzer to Howler sound

旧时模样 提交于 2019-12-05 01:47:25
问题 I have been trying for a while to connect an analyser to a Howler sound without any success. I create my Howler sound like this: var sound = new Howl({ urls: [ '/media/sounds/genesis.mp3', ] }); And then I create my analyser using Howler global context like this: var ctx = Howler.ctx; var analyser = ctx.createAnalyser(); var dataArray = new Uint8Array(analyser.frequencyBinCount); analyser.getByteTimeDomainData(dataArray); I am quite new to the web audio API. I think I am missing a connection

Javascript and Howler.js - how to choose a random sound?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 19:18:40
I am rather new to javascript and trying to have random selected sounds playing on mousemove. I can't get to work and would appreciate help. I am using howler.min.js to control the sound so does not wait for the sound to play to end before it plays the next sound. Here is the code: var soundObjects = []; var lastSoundTime = Date.now(); c.addEventListener("mousemove",function(evt){ var mx = evt.clientX - this.offsetLeft; var my = evt.clientY - this.offsetTop; //console.log("clicked at x:" + mx + ", y:" + my); // circles.push(makeMovingCircle(mx, my)); var now = Date.now(); var elapsed = now -