@@ -2762,11 +2762,13 @@ var LibrarySDL = {
2762
2762
2763
2763
if (bytes !== undefined && SDL.webAudioAvailable() && canPlayWithWebAudio) {
2764
2764
audio = undefined;
2765
- webAudio = {};
2766
- // The audio decoding process is asynchronous, which gives trouble if user code plays the audio data back immediately
2767
- // after loading. Therefore prepare an array of callback handlers to run when this audio decoding is complete, which
2768
- // will then start the playback (with some delay).
2769
- webAudio.onDecodeComplete = []; // While this member array exists, decoding hasn't finished yet.
2765
+ webAudio = {
2766
+ // The audio decoding process is asynchronous, which gives trouble if user
2767
+ // code plays the audio data back immediately after loading. Therefore
2768
+ // prepare an array of callback handlers to run when this audio decoding
2769
+ // is complete, which will then start the playback (with some delay).
2770
+ onDecodeComplete: [], // While this member array exists, decoding hasn't finished yet.
2771
+ }
2770
2772
var onDecodeComplete = (data) => {
2771
2773
webAudio.decodedBuffer = data;
2772
2774
// Call all handlers that were waiting for this decode to finish, and clear the handler list.
@@ -2815,8 +2817,7 @@ var LibrarySDL = {
2815
2817
}
2816
2818
2817
2819
if (SDL.webAudioAvailable()) {
2818
- webAudio = {};
2819
- webAudio.decodedBuffer = buffer;
2820
+ webAudio = { decodedBuffer: buffer };
2820
2821
} else {
2821
2822
audio = new Audio();
2822
2823
audio.mozAudioChannelType = 'content'; // bugzilla 910340
@@ -2873,13 +2874,14 @@ var LibrarySDL = {
2873
2874
var audio;
2874
2875
if (info.webAudio) {
2875
2876
// Create an instance of the WebAudio object.
2876
- audio = {};
2877
- audio.resource = info; // This new object is an instance that refers to this existing resource.
2878
- audio.paused = false;
2879
- audio.currentPosition = 0;
2880
2877
// Make our instance look similar to the instance of a <media> to make api simple.
2881
- audio.play = function() { SDL.playWebAudio(this); }
2882
- audio.pause = function() { SDL.pauseWebAudio(this); }
2878
+ audio = {
2879
+ resource: info, // This new object is an instance that refers to this existing resource.
2880
+ paused: false,
2881
+ currentPosition: 0,
2882
+ play() { SDL.playWebAudio(this); },
2883
+ pause() { SDL.pauseWebAudio(this); },
2884
+ };
2883
2885
} else {
2884
2886
// We clone the audio node to utilize the preloaded audio buffer, since
2885
2887
// the browser has already preloaded the audio file.
@@ -2964,12 +2966,13 @@ var LibrarySDL = {
2964
2966
var audio;
2965
2967
if (info.webAudio) { // Play via Web Audio API
2966
2968
// Create an instance of the WebAudio object.
2967
- audio = {};
2968
- audio.resource = info; // This new webAudio object is an instance that refers to this existing resource.
2969
- audio.paused = false;
2970
- audio.currentPosition = 0;
2971
- audio.play = function() { SDL.playWebAudio(this); }
2972
- audio.pause = function() { SDL.pauseWebAudio(this); }
2969
+ audio = {
2970
+ resource: info, // This new webAudio object is an instance that refers to this existing resource.
2971
+ paused: false,
2972
+ currentPosition: 0,
2973
+ play() { SDL.playWebAudio(this); },
2974
+ pause() { SDL.pauseWebAudio(this); },
2975
+ };
2973
2976
} else if (info.audio) { // Play via the <audio> element
2974
2977
audio = info.audio;
2975
2978
}
0 commit comments