From 57e5f98d26e47a7639d24fa29327584b6fc9f7e7 Mon Sep 17 00:00:00 2001 From: -=yb4f310 Date: Wed, 15 Nov 2017 23:54:41 +0100 Subject: [PATCH] audio ended event --- src/game-lib-a-1-event.js | 4 ++-- src/game-lib-system-audio.js | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/game-lib-a-1-event.js b/src/game-lib-a-1-event.js index 8d14255..48857cf 100644 --- a/src/game-lib-a-1-event.js +++ b/src/game-lib-a-1-event.js @@ -67,7 +67,7 @@ GameLib.Event.MATERIAL_TEXTURES_UPDATED = 0x31; GameLib.Event.DELETE_COMPONENT_ERROR = 0x32; GameLib.Event.COMPONENT_DELETED = 0x33; GameLib.Event.COMPONENT_TYPES_UPDATED = 0x34; -//GameLib.Event.SHAPE_INSTANCE_CREATED = 0x35; +GameLib.Event.AUDIO_ENDED = 0x35; GameLib.Event.COMPONENT_LINKED = 0x36; //GameLib.Event.SOLVER_INSTANCE_CREATED = 0x37; GameLib.Event.BEFORE_RENDER = 0x38; @@ -174,7 +174,7 @@ GameLib.Event.GetEventName = function(number) { case 0x32 : return 'delete_component_error'; case 0x33 : return 'component_deleted'; case 0x34 : return 'component_types_updated'; - case 0x35 : return 'unused';//'shape_instance_created'; + case 0x35 : return 'audio_ended'; case 0x36 : return 'component_linked'; case 0x37 : return 'unused';//'solver_instance_created'; case 0x38 : return 'before_render'; diff --git a/src/game-lib-system-audio.js b/src/game-lib-system-audio.js index b48b96d..2885ae4 100644 --- a/src/game-lib-system-audio.js +++ b/src/game-lib-system-audio.js @@ -82,6 +82,15 @@ GameLib.System.Audio.prototype.playAudio = function(data) { if (audio.name === data.name) { if (!audio.instance.isPlaying) { audio.instance.play(); + + audio.instance.onEnded = function() { + GameLib.Event.Emit( + GameLib.Event.AUDIO_ENDED, + { + audio : audio + } + ); + } } } }