summaryrefslogtreecommitdiff
path: root/scene/audio
diff options
context:
space:
mode:
Diffstat (limited to 'scene/audio')
-rw-r--r--scene/audio/event_player.cpp2
-rw-r--r--scene/audio/stream_player.cpp16
-rw-r--r--scene/audio/stream_player.h1
3 files changed, 17 insertions, 2 deletions
diff --git a/scene/audio/event_player.cpp b/scene/audio/event_player.cpp
index eabe84a8ee..f43c3c2a59 100644
--- a/scene/audio/event_player.cpp
+++ b/scene/audio/event_player.cpp
@@ -54,6 +54,8 @@ void EventPlayer::set_stream(const Ref<EventStream> &p_stream) {
stream=p_stream;
if (stream.is_valid())
playback=stream->instance_playback();
+ else
+ playback.unref();
if (playback.is_valid()) {
diff --git a/scene/audio/stream_player.cpp b/scene/audio/stream_player.cpp
index f7cfc31b03..c1799ec12c 100644
--- a/scene/audio/stream_player.cpp
+++ b/scene/audio/stream_player.cpp
@@ -100,11 +100,22 @@ 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();
+ autoplay = false; //this line fix autoplay issues
+ }
+ }
+
} break;
case NOTIFICATION_EXIT_TREE: {
+ if (is_playing()) {
+ resume_pos=get_pos();
+ }
stop(); //wathever it may be doing, stop
} break;
}
@@ -397,6 +408,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;