Parse queue music and sound

This commit is contained in:
Victor 2015-12-08 12:35:14 +02:00
parent c8edde1dfc
commit cde50d8467
2 changed files with 37 additions and 1 deletions

View File

@ -69,7 +69,7 @@ Parser.prototype.statement = function() {
if (this.match(token, TokenType.COMMAND)) return this.command(); if (this.match(token, TokenType.COMMAND)) return this.command();
if (this.match(token, TokenType.SCENE)) return this.scene(); if (this.match(token, TokenType.SCENE)) return this.scene();
if (this.match(token, TokenType.PLAY)) return this.play(); 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.STOP)) return this.stop();
if (this.match(token, TokenType.SHOW)) return this.show(); if (this.match(token, TokenType.SHOW)) return this.show();
if (this.match(token, TokenType.HIDE)) return this.hide(); if (this.match(token, TokenType.HIDE)) return this.hide();
@ -328,6 +328,24 @@ Parser.prototype.playAmbience = function() {
return false; 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() { Parser.prototype.stop = function() {
if (this.match(TokenType.MUSIC)) { if (this.match(TokenType.MUSIC)) {
var fade = this.matchFade(); var fade = this.matchFade();

View File

@ -323,6 +323,24 @@ Views.prototype.createMenuItemClickFunction = function (index, menu) {
Views.prototype.showGameMenuDialog = function (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) { Views.prototype.music = function (name, fade) {
try { try {
this.stopMusic(this.musicPlayerAudio.fade); this.stopMusic(this.musicPlayerAudio.fade);