Start HTML5 video at a particular position when loading? Start HTML5 video at a particular position when loading? javascript javascript

Start HTML5 video at a particular position when loading?


You have to wait until the browser knows the duration of the video before you can seek to a particular time. So, I think you want to wait for the 'loadedmetadata' event something like this:

document.getElementById('vid1').addEventListener('loadedmetadata', function() {  this.currentTime = 50;}, false);


WITHOUT USING JAVASCRIPT

Just add #t=[(start_time), (end_time)] to the end of your media URL. The only setback (if you want to see it that way) is you'll need to know how long your video is to indicate the end time.Example:

<video>    <source src="splash.mp4#t=10,20" type="video/mp4"></video>

Notes: Not supported in IE


You can link directly with Media Fragments URI, just change the filename to file.webm#t=50

Here's an example

This is pretty cool, you can do all sorts of things. But I don't know the current state of browser support.