summaryrefslogtreecommitdiff
path: root/scene/audio
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-02-02 23:26:20 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-02-02 23:27:10 -0300
commit259bd73caed445b7d36caa31743cd049d6204e98 (patch)
tree8723e27ff7ddcdcfcded1b85d8f5807e4e3e8cc6 /scene/audio
parentdcb823b2934ffddb74ff55aa7ff7f5be9e8c29b4 (diff)
-make stream player and time restore state properly if removed, fixes #1949
Diffstat (limited to 'scene/audio')
-rw-r--r--scene/audio/stream_player.cpp14
-rw-r--r--scene/audio/stream_player.h1
2 files changed, 13 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;