mirror of
https://github.com/google/blockly.git
synced 2026-01-04 23:50:12 +01:00
23 lines
451 B
JavaScript
23 lines
451 B
JavaScript
/**
|
|
* @license
|
|
* Copyright 2017 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
const MusicMaker = {
|
|
queue_: [],
|
|
player_: new Audio(),
|
|
queueSound: function(soundUrl) {
|
|
this.queue_.push(soundUrl);
|
|
},
|
|
play: function() {
|
|
let next = this.queue_.shift();
|
|
if (next) {
|
|
this.player_.src = next;
|
|
this.player_.play();
|
|
}
|
|
},
|
|
};
|
|
|
|
MusicMaker.player_.addEventListener(
|
|
'ended', MusicMaker.play.bind(MusicMaker));
|