Skip to content

Commit 5643c26

Browse files
authored
Use object notation in library_sdl.js. NFC (#23028)
1 parent ac676d5 commit 5643c26

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/library_sdl.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -2762,11 +2762,13 @@ var LibrarySDL = {
27622762
27632763
if (bytes !== undefined && SDL.webAudioAvailable() && canPlayWithWebAudio) {
27642764
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+
}
27702772
var onDecodeComplete = (data) => {
27712773
webAudio.decodedBuffer = data;
27722774
// Call all handlers that were waiting for this decode to finish, and clear the handler list.
@@ -2815,8 +2817,7 @@ var LibrarySDL = {
28152817
}
28162818
28172819
if (SDL.webAudioAvailable()) {
2818-
webAudio = {};
2819-
webAudio.decodedBuffer = buffer;
2820+
webAudio = { decodedBuffer: buffer };
28202821
} else {
28212822
audio = new Audio();
28222823
audio.mozAudioChannelType = 'content'; // bugzilla 910340
@@ -2873,13 +2874,14 @@ var LibrarySDL = {
28732874
var audio;
28742875
if (info.webAudio) {
28752876
// 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;
28802877
// 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+
};
28832885
} else {
28842886
// We clone the audio node to utilize the preloaded audio buffer, since
28852887
// the browser has already preloaded the audio file.
@@ -2964,12 +2966,13 @@ var LibrarySDL = {
29642966
var audio;
29652967
if (info.webAudio) { // Play via Web Audio API
29662968
// 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+
};
29732976
} else if (info.audio) { // Play via the <audio> element
29742977
audio = info.audio;
29752978
}

0 commit comments

Comments
 (0)