Skip to content

Commit 51453b0

Browse files
committed
Handle extra interruption states
stalled/suspend are commented out pending better understanding whether they can be recovered from
1 parent 968a684 commit 51453b0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

music_html5.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ static int MusicHTML5_Open(const SDL_AudioSpec *spec)
101101
Module["SDL2Mixer"].music[id] = new Audio(url);
102102
Module["SDL2Mixer"].music[id].addEventListener("ended", Module["SDL2Mixer"].musicFinished, false);
103103
Module["SDL2Mixer"].music[id].addEventListener("error", Module["SDL2Mixer"].musicError, false);
104+
Module["SDL2Mixer"].music[id].addEventListener("abort", Module["SDL2Mixer"].musicInterrupted, false);
105+
// Can browser recover from these states? If not, consider enabling these.
106+
//Module["SDL2Mixer"].music[id].addEventListener("stalled", Module["SDL2Mixer"].musicInterrupted, false);
107+
//Module["SDL2Mixer"].music[id].addEventListener("suspend", Module["SDL2Mixer"].musicInterrupted, false);
104108
if (context)
105109
Module["SDL2Mixer"].music[id].dataset.context = context;
106110
return id;
@@ -213,6 +217,11 @@ static int MusicHTML5_Open(const SDL_AudioSpec *spec)
213217

214218
// Reset to defaults
215219
this.resetMusicState(audio);
220+
},
221+
222+
musicInterrupted: function(e) {
223+
// Reset to defaults
224+
this.resetMusicState(e.target);
216225
}
217226
};
218227
}), html5_handle_music_stopped);

0 commit comments

Comments
 (0)