Starting the video at time x

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

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

1 Like

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? 
	
	
	
});

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

Ok I found the solution: set keyframe distance value to ā€œ1ā€ in your video export software.

How would we pause the video at a seeked time? If we wanted to play the first 12 seconds and then pause?

Hi @paula.clark,

Iā€™ve replied to your other thread:

All the best,
Seb

1 Like