diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-02-02 23:26:20 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-02-02 23:27:10 -0300 |
commit | 259bd73caed445b7d36caa31743cd049d6204e98 (patch) | |
tree | 8723e27ff7ddcdcfcded1b85d8f5807e4e3e8cc6 /scene | |
parent | dcb823b2934ffddb74ff55aa7ff7f5be9e8c29b4 (diff) |
-make stream player and time restore state properly if removed, fixes #1949
Diffstat (limited to 'scene')
-rw-r--r-- | scene/audio/stream_player.cpp | 14 | ||||
-rw-r--r-- | scene/audio/stream_player.h | 1 | ||||
-rw-r--r-- | scene/main/timer.cpp | 1 |
3 files changed, 14 insertions, 2 deletions
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp index f7cfc31b03..fd18803394 100644 --- a/scene/audio/stream_player.cpp +++ b/scene/audio/stream_player.cpp @@ -100,11 +100,20 @@ void StreamPlayer::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { //set_idle_process(false); //don't annoy - if (stream.is_valid() && autoplay && !get_tree()->is_editor_hint()) - play(); + if (stream.is_valid() && !get_tree()->is_editor_hint()) { + if (resume_pos>=0) { + play(resume_pos); + resume_pos=-1; + } else if (autoplay) { + play(); + } + } } break; case NOTIFICATION_EXIT_TREE: { + if (is_playing()) { + resume_pos=get_pos(); + } stop(); //wathever it may be doing, stop } break; } @@ -397,6 +406,7 @@ StreamPlayer::StreamPlayer() { buffering_ms=500; loop_point=0; stop_request=false; + resume_pos=-1; } diff --git a/scene/audio/stream_player.h b/scene/audio/stream_player.h index 30840137e2..475139c2a4 100644 --- a/scene/audio/stream_player.h +++ b/scene/audio/stream_player.h @@ -67,6 +67,7 @@ class StreamPlayer : public Node { float loop_point; int buffering_ms; volatile bool stop_request; + float resume_pos; AudioRBResampler resampler; diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 2c23b62b12..a118bc9782 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -42,6 +42,7 @@ void Timer::_notification(int p_what) { break; #endif start(); + autostart=false; } } break; case NOTIFICATION_PROCESS: { |