I have an html5 video element.
<video id="video" loop="loop">
<source src="src.mov">
</video>
I want it to start at a certain time in the video (lets say... 10 seconds) and end at a certain time (27 seconds)
I know that you can do this in JavaScript, however I want to do this in html. Is there a start / end time tag for the video element?
Add the parameter data-autoplay="1" inside the <img> tag. If you want the video to start playing at a specific time, also add data-second=15 . Adjust the seconds value as needed.
The loop attribute is a boolean attribute. When present, it specifies that the video will start over again, every time it is finished.
The <video> HTML element embeds a media player which supports video playback into the document.
The HTML 5 <video> tag is used to specify video on an HTML document. For example, you could embed a music video on your web page for your visitors to listen to and watch. The HTML 5 <video> tag accepts attributes that specify how the video should be played. Attributes include preload , autoplay , loop and more.
You can specify a playback range by appending the start and end times to the source URL.
The times should be in the format:
#t=[starttime][,endtime]
From MDN:
The playback range portion of the media element URI specification was added to Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6).
Here's an example to play a video, starting from second 2 and ending at second 3:
<video controls autoplay>
<source src=http://techslides.com/demos/sample-videos/small.webm#t=2,3 type=video/webm>
<source src=http://techslides.com/demos/sample-videos/small.ogv#t=2,3 type=video/ogg>
<source src=http://techslides.com/demos/sample-videos/small.mp4#t=2,3 type=video/mp4>
<source src=http://techslides.com/demos/sample-videos/small.3gp#t=2,3 type=video/3gp>
</video>
References:
Temporal Dimension of Media Fragments URI
Record of Mozilla integration (bug 648595)
Sample videos are from techslides.com
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With