audio system pause updates
parent
ddfdbd29cc
commit
e4a5554c56
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
||||||
var __DATE__ = "Sat Nov 25 2017 08:16:31 GMT+0100 (CET)";
|
var __DATE__ = "Sat Nov 25 2017 11:12:58 GMT+0100 (CET)";
|
||||||
// END COMPILE TIME DEFINITIONS
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3774,6 +3774,7 @@ GameLib.D3.API.Audio = function(
|
||||||
volume,
|
volume,
|
||||||
camera,
|
camera,
|
||||||
overplay,
|
overplay,
|
||||||
|
paused,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -3812,6 +3813,11 @@ GameLib.D3.API.Audio = function(
|
||||||
}
|
}
|
||||||
this.overplay = overplay;
|
this.overplay = overplay;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(paused)) {
|
||||||
|
paused = false;
|
||||||
|
}
|
||||||
|
this.paused = paused;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
parentEntity = null;
|
parentEntity = null;
|
||||||
}
|
}
|
||||||
|
@ -3845,6 +3851,7 @@ GameLib.D3.API.Audio.FromObject = function(objectAudio) {
|
||||||
objectAudio.volume,
|
objectAudio.volume,
|
||||||
apiCamera,
|
apiCamera,
|
||||||
objectAudio.overplay,
|
objectAudio.overplay,
|
||||||
|
objectAudio.paused,
|
||||||
objectAudio.parentEntity
|
objectAudio.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -9065,6 +9072,7 @@ GameLib.D3.Audio = function(
|
||||||
apiAudio.volume,
|
apiAudio.volume,
|
||||||
apiAudio.camera,
|
apiAudio.camera,
|
||||||
apiAudio.overplay,
|
apiAudio.overplay,
|
||||||
|
apiAudio.pause,
|
||||||
apiAudio.parentEntity
|
apiAudio.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -9120,7 +9128,7 @@ GameLib.D3.Audio.prototype.createInstance = function() {
|
||||||
|
|
||||||
//Load a sound and set it as the Audio object's buffer
|
//Load a sound and set it as the Audio object's buffer
|
||||||
audioLoader.load(
|
audioLoader.load(
|
||||||
this.apiUrl + this.path,
|
this.apiUrl + this.path + '?ts=' + Date.now(),
|
||||||
function( buffer ) {
|
function( buffer ) {
|
||||||
this.instance.setBuffer( buffer );
|
this.instance.setBuffer( buffer );
|
||||||
this.instance.setLoop( this.loop );
|
this.instance.setLoop( this.loop );
|
||||||
|
@ -9143,6 +9151,14 @@ GameLib.D3.Audio.prototype.updateInstance = function(property) {
|
||||||
this.instance.setVolume(this.volume);
|
this.instance.setVolume(this.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property === 'paused') {
|
||||||
|
if (this.paused) {
|
||||||
|
this.instance.pause();
|
||||||
|
} else {
|
||||||
|
this.instance.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9159,6 +9175,7 @@ GameLib.D3.Audio.prototype.toApiObject = function() {
|
||||||
this.volume,
|
this.volume,
|
||||||
GameLib.Utils.IdOrNull(this.camera),
|
GameLib.Utils.IdOrNull(this.camera),
|
||||||
this.overplay,
|
this.overplay,
|
||||||
|
this.paused,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -25649,18 +25666,33 @@ GameLib.System.Audio.prototype.start = function() {
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
GameLib.System.Audio.prototype.instanceCreated = function(data) {
|
GameLib.System.Audio.prototype.instanceCreated = function(data) {
|
||||||
|
|
||||||
if (data.component instanceof GameLib.D3.Audio) {
|
if (data.component instanceof GameLib.D3.Audio) {
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.audioComponents, data.component);
|
GameLib.Utils.PushUnique(this.audioComponents, data.component);
|
||||||
|
|
||||||
|
data.component.instance.onEnded = function() {
|
||||||
|
this.isPlaying = false;
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.AUDIO_ENDED,
|
||||||
|
{
|
||||||
|
audio : data.component
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
var index = this.toPlay.indexOf(data.component.name);
|
var index = this.toPlay.indexOf(data.component.name);
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.PLAY_AUDIO,
|
GameLib.Event.PLAY_AUDIO,
|
||||||
{
|
{
|
||||||
name : data.component.name
|
name : data.component.name
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
|
this.toPlay.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -25683,25 +25715,14 @@ GameLib.System.Audio.prototype.playAudio = function(data) {
|
||||||
console.log('audio not ready yet');
|
console.log('audio not ready yet');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio.instance.isPlaying && audio.overplay) {
|
if (audio.overplay) {
|
||||||
|
if (audio.instance.isPlaying) {
|
||||||
audio.instance.stop();
|
audio.instance.stop();
|
||||||
}
|
}
|
||||||
|
audio.instance.offset = 0;
|
||||||
if (!audio.instance.isPlaying) {
|
audio.instance.play();
|
||||||
|
} else if (!audio.instance.isPlaying) {
|
||||||
audio.instance.play();
|
audio.instance.play();
|
||||||
|
|
||||||
audio.instance.onEnded = function() {
|
|
||||||
|
|
||||||
this.isPlaying = false;
|
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.AUDIO_ENDED,
|
|
||||||
{
|
|
||||||
audio : audio
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25723,8 +25744,11 @@ GameLib.System.Audio.prototype.pauseAllAudio = function(data) {
|
||||||
this.audioComponents.map(
|
this.audioComponents.map(
|
||||||
function(audio) {
|
function(audio) {
|
||||||
if (audio.instance.isPlaying) {
|
if (audio.instance.isPlaying) {
|
||||||
audio.instance.pause();
|
|
||||||
this.paused.push(audio);
|
this.paused.push(audio);
|
||||||
|
// audio.currentTime = audio.instance.context.currentTime;
|
||||||
|
audio.paused = true;
|
||||||
|
audio.updateInstance('paused');
|
||||||
|
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
)
|
||||||
|
@ -25734,10 +25758,14 @@ GameLib.System.Audio.prototype.continueAllAudio = function(data) {
|
||||||
|
|
||||||
this.paused.map(
|
this.paused.map(
|
||||||
function(audio) {
|
function(audio) {
|
||||||
audio.instance.play();
|
// audio.instance.context.currentTime = audio.currentTime;
|
||||||
|
audio.paused = false;
|
||||||
|
audio.updateInstance('paused');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.paused = [];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Audio.prototype.stopAllAudio = function(data) {
|
GameLib.System.Audio.prototype.stopAllAudio = function(data) {
|
||||||
|
@ -30541,6 +30569,10 @@ GameLib.System.Render.prototype.instanceCreated = function(data) {
|
||||||
this.renderers.push(data.component);
|
this.renderers.push(data.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.D3.Stats) {
|
||||||
|
console.log('new stats');
|
||||||
|
this.statistics.push(data.component);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,6 +18,7 @@ GameLib.D3.API.Audio = function(
|
||||||
volume,
|
volume,
|
||||||
camera,
|
camera,
|
||||||
overplay,
|
overplay,
|
||||||
|
paused,
|
||||||
parentEntity
|
parentEntity
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -56,6 +57,11 @@ GameLib.D3.API.Audio = function(
|
||||||
}
|
}
|
||||||
this.overplay = overplay;
|
this.overplay = overplay;
|
||||||
|
|
||||||
|
if (GameLib.Utils.UndefinedOrNull(paused)) {
|
||||||
|
paused = false;
|
||||||
|
}
|
||||||
|
this.paused = paused;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
||||||
parentEntity = null;
|
parentEntity = null;
|
||||||
}
|
}
|
||||||
|
@ -89,6 +95,7 @@ GameLib.D3.API.Audio.FromObject = function(objectAudio) {
|
||||||
objectAudio.volume,
|
objectAudio.volume,
|
||||||
apiCamera,
|
apiCamera,
|
||||||
objectAudio.overplay,
|
objectAudio.overplay,
|
||||||
|
objectAudio.paused,
|
||||||
objectAudio.parentEntity
|
objectAudio.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ GameLib.D3.Audio = function(
|
||||||
apiAudio.volume,
|
apiAudio.volume,
|
||||||
apiAudio.camera,
|
apiAudio.camera,
|
||||||
apiAudio.overplay,
|
apiAudio.overplay,
|
||||||
|
apiAudio.pause,
|
||||||
apiAudio.parentEntity
|
apiAudio.parentEntity
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ GameLib.D3.Audio.prototype.createInstance = function() {
|
||||||
|
|
||||||
//Load a sound and set it as the Audio object's buffer
|
//Load a sound and set it as the Audio object's buffer
|
||||||
audioLoader.load(
|
audioLoader.load(
|
||||||
this.apiUrl + this.path,
|
this.apiUrl + this.path + '?ts=' + Date.now(),
|
||||||
function( buffer ) {
|
function( buffer ) {
|
||||||
this.instance.setBuffer( buffer );
|
this.instance.setBuffer( buffer );
|
||||||
this.instance.setLoop( this.loop );
|
this.instance.setLoop( this.loop );
|
||||||
|
@ -107,6 +108,14 @@ GameLib.D3.Audio.prototype.updateInstance = function(property) {
|
||||||
this.instance.setVolume(this.volume);
|
this.instance.setVolume(this.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (property === 'paused') {
|
||||||
|
if (this.paused) {
|
||||||
|
this.instance.pause();
|
||||||
|
} else {
|
||||||
|
this.instance.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,6 +132,7 @@ GameLib.D3.Audio.prototype.toApiObject = function() {
|
||||||
this.volume,
|
this.volume,
|
||||||
GameLib.Utils.IdOrNull(this.camera),
|
GameLib.Utils.IdOrNull(this.camera),
|
||||||
this.overplay,
|
this.overplay,
|
||||||
|
this.paused,
|
||||||
GameLib.Utils.IdOrNull(this.parentEntity)
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -93,18 +93,33 @@ GameLib.System.Audio.prototype.start = function() {
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
GameLib.System.Audio.prototype.instanceCreated = function(data) {
|
GameLib.System.Audio.prototype.instanceCreated = function(data) {
|
||||||
|
|
||||||
if (data.component instanceof GameLib.D3.Audio) {
|
if (data.component instanceof GameLib.D3.Audio) {
|
||||||
|
|
||||||
GameLib.Utils.PushUnique(this.audioComponents, data.component);
|
GameLib.Utils.PushUnique(this.audioComponents, data.component);
|
||||||
|
|
||||||
|
data.component.instance.onEnded = function() {
|
||||||
|
this.isPlaying = false;
|
||||||
|
GameLib.Event.Emit(
|
||||||
|
GameLib.Event.AUDIO_ENDED,
|
||||||
|
{
|
||||||
|
audio : data.component
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
var index = this.toPlay.indexOf(data.component.name);
|
var index = this.toPlay.indexOf(data.component.name);
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.PLAY_AUDIO,
|
GameLib.Event.PLAY_AUDIO,
|
||||||
{
|
{
|
||||||
name : data.component.name
|
name : data.component.name
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
|
this.toPlay.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -127,25 +142,14 @@ GameLib.System.Audio.prototype.playAudio = function(data) {
|
||||||
console.log('audio not ready yet');
|
console.log('audio not ready yet');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (audio.instance.isPlaying && audio.overplay) {
|
if (audio.overplay) {
|
||||||
|
if (audio.instance.isPlaying) {
|
||||||
audio.instance.stop();
|
audio.instance.stop();
|
||||||
}
|
}
|
||||||
|
audio.instance.offset = 0;
|
||||||
if (!audio.instance.isPlaying) {
|
audio.instance.play();
|
||||||
|
} else if (!audio.instance.isPlaying) {
|
||||||
audio.instance.play();
|
audio.instance.play();
|
||||||
|
|
||||||
audio.instance.onEnded = function() {
|
|
||||||
|
|
||||||
this.isPlaying = false;
|
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
|
||||||
GameLib.Event.AUDIO_ENDED,
|
|
||||||
{
|
|
||||||
audio : audio
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,8 +171,11 @@ GameLib.System.Audio.prototype.pauseAllAudio = function(data) {
|
||||||
this.audioComponents.map(
|
this.audioComponents.map(
|
||||||
function(audio) {
|
function(audio) {
|
||||||
if (audio.instance.isPlaying) {
|
if (audio.instance.isPlaying) {
|
||||||
audio.instance.pause();
|
|
||||||
this.paused.push(audio);
|
this.paused.push(audio);
|
||||||
|
// audio.currentTime = audio.instance.context.currentTime;
|
||||||
|
audio.paused = true;
|
||||||
|
audio.updateInstance('paused');
|
||||||
|
|
||||||
}
|
}
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
)
|
)
|
||||||
|
@ -178,10 +185,14 @@ GameLib.System.Audio.prototype.continueAllAudio = function(data) {
|
||||||
|
|
||||||
this.paused.map(
|
this.paused.map(
|
||||||
function(audio) {
|
function(audio) {
|
||||||
audio.instance.play();
|
// audio.instance.context.currentTime = audio.currentTime;
|
||||||
|
audio.paused = false;
|
||||||
|
audio.updateInstance('paused');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.paused = [];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.Audio.prototype.stopAllAudio = function(data) {
|
GameLib.System.Audio.prototype.stopAllAudio = function(data) {
|
||||||
|
|
|
@ -58,6 +58,10 @@ GameLib.System.Render.prototype.instanceCreated = function(data) {
|
||||||
this.renderers.push(data.component);
|
this.renderers.push(data.component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.component instanceof GameLib.D3.Stats) {
|
||||||
|
console.log('new stats');
|
||||||
|
this.statistics.push(data.component);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue