I'm New - VideoPlayer VCR Conrols

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By pixelinkmedia

Hi,

I got the videoplayer to load my video.
I turn off “autoplay” in inspector

When I run the game, the video doesn’t play, as I expected.

But there are no VCR-like controls to play/pause/stop etc.
Where is that setting??

Also, when I export a game to windows exe, does the video require any special run times or codecs’s to be on the pc… in other words is the game dependent on user’s pc having any required programs (Media player etc) or are they required to install any prerequisites before using the game.

Thanks

:bust_in_silhouette: Reply From: kidscancode

If you want video controls in your game, you’ll have to make them with Control nodes such as Buttons. You can attach them to VideoPlayer methods (ie play() and stop()).

No, the user doesn’t need anything installed for Godot to work. Video (Webm and Ogg Theora) libraries are built in.

Okay… I made a play and stop button… that works okay.

One problem.

I really need a pause button that pauses the video so when the user presses the Play button again it will continue where it was paused.

However, currently with my stop button. If i press play again, it starts the video over from the beginning… that is not what i need. I need it to play from where i stopped (or paused) it.

Can that be done?

Thanks

pixelinkmedia | 2019-06-10 00:14

The VideoPlayer docs contain all the information you need. In this case, the paused property.

kidscancode | 2019-06-10 00:16

I read that… very basic and not much info.
Doesn’t explain my situation at all.

I tried just using “pause” but clicking play starts the video over from beginning.

UPDATED
THIS IS WORNG… see below post

pixelinkmedia | 2019-06-10 00:23

Sorry… mis-spoke… this code doesn’t even work,

VideoPlayer.pause

pixelinkmedia | 2019-06-10 00:26

Here is what I have for code for play and pause buttons

func _on_Button_pressed():
	$CanvasLayer/VideoPlayer.play()

func _on_Pause_pressed():
	#$CanvasLayer/VideoPlayer.stop()
	$CanvasLayer/VideoPlayer.paused

pixelinkmedia | 2019-06-10 00:32

I tried this… and it paused the video.

$CanvasLayer/VideoPlayer.set_paused(true)

Now if I can get the play to work right

pixelinkmedia | 2019-06-10 00:53

Okay… figured it out…

The play and pause buttons both work.

func _on_Button_pressed():
	if $CanvasLayer/VideoPlayer.is_paused():
	   $CanvasLayer/VideoPlayer.set_paused(false)
	else:
		$CanvasLayer/VideoPlayer.play()

func _on_Pause_pressed():
	$CanvasLayer/VideoPlayer.set_paused(true)

pixelinkmedia | 2019-06-10 00:58

Good work. FYI, set/get are not necessary for object properties:

func _on_Button_pressed():
    if $CanvasLayer/VideoPlayer.paused:
       $CanvasLayer/VideoPlayer.paused = false
    else:
        $CanvasLayer/VideoPlayer.play()

func _on_Pause_pressed():
    $CanvasLayer/VideoPlayer.paused = true

kidscancode | 2019-06-10 01:06

Okay. That works too.

Thanks

pixelinkmedia | 2019-06-10 10:11