Starting the video at time x


#1

Hi,

Trying to get the video to start in a couple of seconds in the video. What am i doing wrong here?

videoplayer.on("video:playing", () => {

videoplayer.nodes.control.time(t: 9000); 

});

using this: https://docs.zap.works/studio/subsymbols/templates/video-player-symbol/ and working based on this demo: https://docs.zap.works/studio/tutorials/streaming-video-in-the-3d-view


#3

Hi there,

If you have a Z.Video object in your scene you can use the time(...) function to seek the video to the specified time.

The time function takes in the time you’d like to seek the video to (in milliseconds) as an argument so you should use .time(9000) instead.

Also, the .time() function is being called within the .on("playing") event handler, which is fired once the video is already playing.

Instead, you could set the time to seek the video to with the .time(...) function first, and then use the .start() function to play the video from the time specified.

Hope this helps.

Thanks,
Seb


#4

Thanks Sebastian for taking the time to reply. Trying to learn here so that really helps :slight_smile: While the docs is really helpfull, i’m hoping to find some more coding examples here on the forum.

Because there’s not that many coding examples I’m having problems understanding how to use code to for example initiate things. I’m not new to coding (Python) and i learn best from reading other code examples. Is there any way to write it out in an example? For example, i don’t have a z.video object. What i’ve found working easiest is just have the video loaded from a URL in a videoplayer symbol.

How would you use a z.video object in a script, have the video loaded from a URL maybe in to a videoplayer and then have it start 9 seconds in?

And then, how can i initiate/start a video based on a button?

Thanks in advance!
Mitsjol

edit example:

const videoplayer = symbol.nodes.videoplayer0;

const video = Z.Video("http://website.nl/url/to/video.mp4")

parent.on("pointerdown", (e) => {
	// Runs when pointerdown occurs on the parent node
	// The argument e contains useful info about this event:
	// https://docs.zap.works/studio/scripting/reference/object/events/pointerdown/
	
	video.start(); // how do i know where this is positioned? can i make it invisible untill it starts?
	
	videoplayer.start(); // start funtion doesn't exist for a videoplayer symbol, right? 
	
	
	
});

#5

Hi again,

The start() and time() functions can’t be called directly on the video player symbol, these are exported by the subsymbol which you can access from a parent symbol.

The method is described here, under the ‘Exported Functions’ section.

To create a button that holds this functionality you’ll need to create a pointerdown script and add the video player functions within the pointerdown event handler.

This docs article on creating a button in Studio should come in handy.

Hope this helps.

All the best,
Seb