我期望在不支持使用JavaScript的循環標記(ff)的瀏覽器中啓用html5視頻循環。有誰知道訪問視頻播放結束的可行性並將播放恢復爲零?使用JavaScript控制html5視頻播放器循環
5
A
回答
15
您可以檢測到loop
屬性是否受支持,並將其設置爲true
。
對於不支持的話,你可以簡單地綁定ended
媒體活動,並啓動它在瀏覽器:
var myVideo = document.getElementById('videoId');
if (typeof myVideo.loop == 'boolean') { // loop supported
myVideo.loop = true;
} else { // loop property not supported
myVideo.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
}
//...
myVideo.play();
0
<div>Iteration: <span id="iteration"></span></div>
<video id="video-background" autoplay="" muted="" controls>
<source src="https://res.sdfdsf.mp4" type="video/mp4">
</video>
var iterations = 1;
document.getElementById('iteration').innerText = iterations;
var myVideo = document.getElementById('video-background');
myVideo.addEventListener('ended', function() {
alert('end');
if (iterations < 2) {
this.currentTime = 0;
this.play();
iterations ++;
document.getElementById('iteration').innerText = iterations;
}
}, false);
// Please note that loop attribute should not be there in video element in order for the 'ended' event to work in ie and firefox
1
你可以簡單地環上的視頻或關閉通過loop="false"
停止自動視頻重複播放。
<iframe style="position: absolute; top: 0; left: 0;"
src="http://video/name.mp4" width="100%" height="100%" frameborder="0" webkitallowfullscreen loop="true" controls="false" mozallowfullscreen allowfullscreen></iframe>
這loop="true"
將啓用視頻播放器循環。
相關問題
- 1. html5視頻播放器播放列表循環
- 2. 停止循環播放HTML5視頻
- 3. 如何使用COSTUM控件創建HTML5 JavaScript視頻播放器?
- 4. 在Facebook中控制HTML5視頻播放
- 5. 使用Javascript播放HTML5視頻
- 6. 使用javascript循環的HTML5視頻
- 7. html5使用什麼視頻播放器?
- 8. html5視頻播放器
- 9. html5 mp4視頻播放器
- 10. 循環播放YouTube視頻
- 11. 播放/循環播放視頻
- 12. HTML5視頻播放器,僅循環特定幀
- 13. 播放視頻HTML5
- 14. 僅當視頻播放時使用視頻控件(html5)
- 15. 使用html5播放視頻和音頻?
- 16. 在iPhone上循環播放HTML5音頻
- 17. 帶控件的HTML5視頻播放器+懸停播放
- 18. 使用javascript播放音頻(無HTML5或可見播放器)
- 19. Flash視頻播放器:JavaScript控件
- 20. 使用html5視頻播放器播放視頻後重定向頁面
- 21. Android與控制器播放視頻
- 22. 播放暫停HTML5視頻的JavaScript
- 23. html5視頻播放列表 - 沒有javascript?
- 24. HTML5視頻播放器轉換器
- 25. 在Android中使用Html5播放視頻
- 26. 使用html5自動播放mp4視頻
- 27. 使用jquery播放/暫停HTML5視頻
- 28. 使用HTML5播放視頻和聲音
- 29. HTML5視頻無法播放
- 30. 播放視頻HTML5和Apache