-make stream player and time restore state properly if removed, fixes #1949
This commit is contained in:
parent
dcb823b293
commit
259bd73cae
3 changed files with 14 additions and 2 deletions
|
@ -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())
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,7 @@ class StreamPlayer : public Node {
|
|||
float loop_point;
|
||||
int buffering_ms;
|
||||
volatile bool stop_request;
|
||||
float resume_pos;
|
||||
|
||||
AudioRBResampler resampler;
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ void Timer::_notification(int p_what) {
|
|||
break;
|
||||
#endif
|
||||
start();
|
||||
autostart=false;
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_PROCESS: {
|
||||
|
|
Loading…
Reference in a new issue