CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

Why does audio on iOS stop when unplugging headphones? #332

Open Sahulhameed9094 opened 8 months ago

Sahulhameed9094 commented 8 months ago

When playing the audio using soundJS and unplugging the headphones, audio is not playing in the speaker, but it runs in the background without any sound and calls the complete function. Could you please take a look at the code below? thanks

 function load() {
 var queue = new createjs.LoadQueue();
  createjs.Sound.alternateExtensions = ["mp3"];
  queue.installPlugin(createjs.Sound);
  queue.addEventListener("fileload", handleFileLoad);
  queue.addEventListener("complete", handleComplete);
  queue.loadManifest({
    id: "audio_1",
    src: "http://commondatastorage.googleapis.com/codeskulptor-demos/DDR_assets/Kangaroo_MusiQue_-_The_Neverwritten_Role_Playing_Game.mp3",
  });
  }

function playIt() {
var instance = createjs.Sound.play('audio_1');
  instance.on("complete", handleComplete2, this);
  instance.on("error", function (e) { console.error(e); }, this);
}