Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seek to a point in html5 video

Is it possible to seek to a particular point in html5 video displayed in a web page? I mean ,can I input a particular time value (say 01:20:30:045 ) and have the player control (slider) move to that point and play from that point onwards?

In older version of mozilla vlcplugin I think this is possible by seek(seconds,is_relative) method..but I would like to know if this is possible in html video.

Edit:

I created the page with video and added javascript as below.When I click on the link ,it displays the time of click..but it doesn't increment the play location..but continues to play normally.

Shouldn't the video play location get changed?

html

<video id="vid" width="640" height="360" controls>        <source src="/myvid/test.mp4" type="video/mp4" />  </video> <a id="gettime" href="#">time</a> <p> you clicked at:<span id="showtime"> </span>  </p> 

javascript

$(document).ready(function(){     var player = $('#vid').get(0);     $('#gettime').click(function(){             if(player){                 current_time=player.currentTime;                 $('#showtime').html(current_time+" seconds");                 player.currentTime=current_time+10;             }         }); } ); 
like image 226
damon Avatar asked May 05 '12 12:05

damon


People also ask

Which tag is used to insert video on web page in HTML5?

The <video> tag is used to embed video content in a document, such as a movie clip or other video streams. The <video> tag contains one or more <source> tags with different video sources. The browser will choose the first source it supports.

What three video types can be used with HTML 5 video?

The HTML5 video format capabilities include three options to play: MP4, WebM, and Ogg. You should note that the Safari browser does not support Ogg, WebM is supported by only 58% of browsers, and MP4 is disabled by default in Firefox 24.

Which of the following video format is not supported in HTML 5?

". wmv" video files are not supported by any browser.


1 Answers

You can use v.currentTime = seconds; to seek to a given position.

Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime

like image 173
ThiefMaster Avatar answered Sep 29 '22 19:09

ThiefMaster