File "music_maker.js"
Full path: /usr/home/mndrn/domains/mndrn.ru/public_html/block-hill/blockly/demos/codelab/app-complete/scripts/music_maker.js
File size: 451 B
MIME-type: text/plain
Charset: utf-8
/**
* @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));