Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html5 video element, start and end times

Tags:

html

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?

like image 542
Ian Wise Avatar asked Oct 30 '14 23:10

Ian Wise


People also ask

How do you start a video at a certain time in HTML?

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.

How do you specify that the video will start over again every time it is finished?

The loop attribute is a boolean attribute. When present, it specifies that the video will start over again, every time it is finished.

What is the correct HTML5 element for playing video files?

The <video> HTML element embeds a media player which supports video playback into the document.

What are the attributes of the HTML5 video element?

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.


1 Answers

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

like image 141
showdev Avatar answered Sep 19 '22 23:09

showdev