From cde50d8467299349e48ae0dcee621fcd964157ac Mon Sep 17 00:00:00 2001 From: Victor Date: Tue, 8 Dec 2015 12:35:14 +0200 Subject: [PATCH] Parse queue music and sound --- public_html/js/Parser.js | 20 +++++++++++++++++++- public_html/js/Views.js | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/public_html/js/Parser.js b/public_html/js/Parser.js index c8a7b92..624c520 100644 --- a/public_html/js/Parser.js +++ b/public_html/js/Parser.js @@ -69,7 +69,7 @@ Parser.prototype.statement = function() { if (this.match(token, TokenType.COMMAND)) return this.command(); if (this.match(token, TokenType.SCENE)) return this.scene(); if (this.match(token, TokenType.PLAY)) return this.play(); -// if (this.match(token, TokenType.QUEUE)) return this.queue(); + if (this.match(token, TokenType.QUEUE)) return this.queue(); if (this.match(token, TokenType.STOP)) return this.stop(); if (this.match(token, TokenType.SHOW)) return this.show(); if (this.match(token, TokenType.HIDE)) return this.hide(); @@ -328,6 +328,24 @@ Parser.prototype.playAmbience = function() { return false; }; +Parser.prototype.queue = function() { + if (this.match(TokenType.MUSIC)) return this.queueMusic(); + if (this.match(TokenType.SOUND)) return this.queueSound(); + return false; +}; + +Parser.prototype.queueMusic = function() { + var name = this.consumeMusicName(); + ViewActivity.getInstance().addMusicToQueue(name); + return false; +}; + +Parser.prototype.queueSound = function() { + var name = this.consumeMusicName(); + ViewActivity.getInstance().addSoundToQueue(name); + return false; +}; + Parser.prototype.stop = function() { if (this.match(TokenType.MUSIC)) { var fade = this.matchFade(); diff --git a/public_html/js/Views.js b/public_html/js/Views.js index 1e64343..7ff5b8a 100644 --- a/public_html/js/Views.js +++ b/public_html/js/Views.js @@ -323,6 +323,24 @@ Views.prototype.createMenuItemClickFunction = function (index, menu) { Views.prototype.showGameMenuDialog = function (menu) { }; +Views.prototype.addMusicToQueue = function (name) { + if (!this.musicPlayerAudio.paused) { + // Если музыка играет, просто добавляем в очередь + this.musicQueue.push(name); + } else { + // Воспроизводим + this.music(name, this.NO_FADE); + } +}; + +Views.prototype.addSoundToQueue = function (name) { + if (!this.soundPlayerAudio.paused) { + this.soundQueue.push(name); + } else { + this.sound(name, false, this.NO_FADE); + } +}; + Views.prototype.music = function (name, fade) { try { this.stopMusic(this.musicPlayerAudio.fade);