@@ -82,9 +82,9 @@ static int MusicHTML5_Open(const SDL_AudioSpec *spec)
82
82
83
83
// TODO: Match blob by ptr and size so we don't duplicate
84
84
85
- if (!(url in Module [ "SDL2Mixer" ] .blob ))
86
- Module [ "SDL2Mixer" ] .blob [url ] = 0 ;
87
- Module [ "SDL2Mixer" ] .blob [url ]++ ;
85
+ if (!(url in this .blob ))
86
+ this .blob [url ] = 0 ;
87
+ this .blob [url ]++ ;
88
88
89
89
return url ;
90
90
},
@@ -97,16 +97,17 @@ static int MusicHTML5_Open(const SDL_AudioSpec *spec)
97
97
},
98
98
99
99
createMusic : function (url , context ) {
100
- const id = Module ["SDL2Mixer" ].getNewId ();
101
- Module ["SDL2Mixer" ].music [id ] = new Audio (url );
102
- Module ["SDL2Mixer" ].music [id ].addEventListener ("ended" , Module ["SDL2Mixer" ].musicFinished , false);
103
- 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);
100
+ const id = this .getNewId ();
101
+ this .music [id ] = new Audio (url );
102
+ this .music [id ].addEventListener ("ended" , this .musicFinished , false);
103
+ this .music [id ].addEventListener ("error" , this .musicError , false);
104
+ this .music [id ].addEventListener ("abort" , this .musicInterrupted , false);
105
+ // Can browser recover from these states? If not, consider enabling these
106
+ // as well as the corresponding removeEventListeners in deleteMusic().
107
+ //this.music[id].addEventListener("stalled", this.musicInterrupted, false);
108
+ //this.music[id].addEventListener("suspend", this.musicInterrupted, false);
108
109
if (context )
109
- Module [ "SDL2Mixer" ] .music [id ].dataset .context = context ;
110
+ this .music [id ].dataset .context = context ;
110
111
return id ;
111
112
},
112
113
@@ -121,6 +122,12 @@ static int MusicHTML5_Open(const SDL_AudioSpec *spec)
121
122
this .music [id ].load ();
122
123
this .music [id ].remove ();
123
124
125
+ this .music [id ].removeEventListener ("ended" , this .musicFinished , false);
126
+ this .music [id ].removeEventListener ("error" , this .musicError , false);
127
+ this .music [id ].removeEventListener ("abort" , this .musicInterrupted , false);
128
+ //this.music[id].removeEventListener("stalled", this.musicInterrupted, false);
129
+ //this.music[id].removeEventListener("suspend", this.musicInterrupted, false);
130
+
124
131
delete this .music [id ];
125
132
126
133
this .deleteBlob (url );
0 commit comments