Files
blockly/demos/codelab/app/scripts/music_maker.js
Neil Fraser 4e2f8e6e02 Use SPDX licences.
This is a followup to #3127.
At the time, SPDX licenses were pending approval by Google.
2020-02-11 13:27:20 -08:00

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));