diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-08-25 11:58:21 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-08-25 11:58:21 -0300 |
commit | a1c03a69d2940fb69d7221800e919f4a183fec0c (patch) | |
tree | b2fc2c52657afd5cea55291a2bb70d1262a5334a /scene/audio | |
parent | 3061eca1902a79668d09a4119e24a42bdd9c8a3a (diff) |
added finished signals to audio stream players, fixes #9928
Diffstat (limited to 'scene/audio')
-rw-r--r-- | scene/audio/audio_player.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index d4d8f7dbed..5f3ff9efe7 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -107,6 +107,15 @@ void AudioStreamPlayer::_notification(int p_what) { } } + if (p_what == NOTIFICATION_INTERNAL_PROCESS) { + + if (!active || (setseek < 0 && !stream_playback->is_playing())) { + active = false; + emit_signal("finished"); + set_process_internal(false); + } + } + if (p_what == NOTIFICATION_EXIT_TREE) { AudioServer::get_singleton()->remove_callback(_mix_audios, this); @@ -158,6 +167,7 @@ void AudioStreamPlayer::play(float p_from_pos) { mix_volume_db = volume_db; //reset volume ramp setseek = p_from_pos; active = true; + set_process_internal(true); } } @@ -172,6 +182,7 @@ void AudioStreamPlayer::stop() { if (stream_playback.is_valid()) { active = false; + set_process_internal(false); } } @@ -297,6 +308,8 @@ void AudioStreamPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "is_autoplay_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mix_target", PROPERTY_HINT_ENUM, "Stereo,Surround,Center"), "set_mix_target", "get_mix_target"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); + + ADD_SIGNAL(MethodInfo("finished")); } AudioStreamPlayer::AudioStreamPlayer() { |