I am developing an app with Ionic and I used web audio API to play audios on ios. After building the app for ios, it can play audio by using web audio and stop normally, but when I used another app for a while or turned off the screen, opening my app again. The app can not play audios. I need to close the app and start it again, then it can play audio, but the same problem will happen again. The codes which play audios are listed below and I enabled the background mode every time when I loaded the audio and disabled the mode after stoping:
this.source_loop = this.audioContext.createBufferSource(); // creates a sound source this.source_loop.buffer = buffer; // tell the source which sound to play this.source_loop.loop = true; this.source_loop.connect(this.audioContext.destination); // connect the source to the context's destination (the speakers) if (this.source_loop.start) { this.source_loop.start(0); } else { this.source_loop.noteOn(0); }
Aucun commentaire:
Enregistrer un commentaire