簡體   English   中英

使用HTML5設置視頻播放的持續時間

[英]Set Duration of video playback with HTML5

我有一個使用TimeJump.js( http://davatron5000.github.io/TimeJump/ )的簡單HTML5視頻播放器,可以直接跳轉到特定的時間代碼。

IE跳至視頻的第25分鍾。

我想增加播放視頻的持續時間。 因此,用戶一次只能觀看60秒的視頻。 我無法使用媒體URL規范(即#t = 25,85),因為視頻的開頭將根據用戶輸入的URL字符串進行更改(使用TimeJump.js跳到視頻中的位置)

關於如何限制視頻播放時間的任何想法?

謝謝。

我從未使用過TimeJump.js,但您可以收聽media元素(音頻和視頻)的timeupdate事件。

 var video = document.querySelector('video'); video.addEventListener('timeupdate', function() { // don't have set the startTime yet? set it to our currentTime if (!this._startTime) this._startTime = this.currentTime; var playedTime = this.currentTime - this._startTime; if (playedTime >= 10) this.pause(); }); video.addEventListener('seeking', function() { // reset the timeStart this._startTime = undefined; }); 
 <video controls="true" height="200" width="300"> <source type="video/ogg" src="http://media.w3.org/2010/05/bunny/movie.ogv"> <source type="video/mp4" src="http://media.w3.org/2010/05/bunny/movie.mp4"> </video> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM