cat
cat

Reputation: 749

How can I let the video start playing at particular position when after the page is loaded?

When after the page is loaded, I want to let the video start playing at 50 sec.
How can I code for that?

My current code is just like this.

<video id="video" controls="controls" autoplay="autoplay" name="media"><source src="video.mp4" type="video/mp4"></video>

<button name="test" onclick="alert(Math.floor(document.getElementById('video').currentTime) + ' secs elapsed!');">How much time has already elapsed?</button>

Upvotes: 0

Views: 66

Answers (1)

dm03514
dm03514

Reputation: 55942

This post and MDN documentation suggests you can just set the video element currentTime = 50 when the page loads.

setting currentTime should seek to the value you set it to

Upvotes: 2

Related Questions