The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

I have a scene playing a video. I would like to change the scene and continue that video on the new scene from where it left off. I'm passing the stream_position of the video through a global variable.

However, when I use videoPlayerNode.set_stream_position(global.stream_position) then play the video, it still starts from the beginning despite global.stream_position being > 0. I have attempted setting the stream position after playing the video, but that does not work either.

What is the proper way to start a video at a certain position?

in Engine by (18 points)

1 Answer

+1 vote
Best answer

If setting stream position from a valid position doesn't work, it sounds like a bug with the node. Or maybe there is an order between the time you play and the time you seek? If it doesn't work either it could be reported on the issue tracker.

Instead of saving the stream position, a workaround would be to not destroy the video player when you change scenes, keep the whole node around in a branch of the tree that doesn't get wiped out (like an autoload) or tweak your game so that it doesn't need to use change_scene, instead change only a child branch (because change_scene is only a shortcut to replace the first child of the scene tree root with another instance).

- CurrentLevel <-- if this is swapped it will wipe VideoPlayer
    - VideoPlayer
    - Other stuff

- VideoPlayer
- CurrentLevel <-- this can be swapped without wiping VideoPlayer
    - Other stuff
by (29,360 points)
selected by

I was able to make it work by playing the video in an AutoLoad. Then I can just remove it as a child from the first scene, and add it as a child of the new scene and it will still be playing at the same point. Thanks!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.