简体   繁体   中英

Android playing audio once

Problem with the audio on Android (HTML5/Javascript program in the native web browser). Works fine on desktop Chrome and iPad Safari. However on Android native browser the audio plays once and then will not play again if called.

Audio is initialised by the user tapping on an image which calls a routine :

function init_audio() { //User audio loading
  for (i=0; i<num_audio; i++){
    audio[i].load();}
  localStorage[8] = "true"; //Local flag to indicate done
}

Whenever required, the audio call is simply:

audio[i].play();

If there was any errors with normal loading and playing, then I'm not sure why it would work at all. Every audio clip loaded will play once each, then not again.

In order to invoke your media player again, first you have to "clear" (release) it.

Try this before your "audio[i].play();"

if (audio[i] != null) if(audio[i].isPlaying()) audio[i].stop();
audio[i].release();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM