[英]Start playing HTML5 Video only after the complete video is buffered
有沒有一種方法可以在整個視頻緩沖后(100%)開始播放我的 HTML5 MP4 視頻。 當它在緩沖過程中時,我應該顯示加載屏幕。 請幫忙。 此代碼應該在 Firefox 和 IE11 中都可以使用。
超鏈接標題示例: - 播放視頻 1:喜歡的食物 - 播放視頻 1:喜歡的蔬菜 - 播放視頻 2:喜歡的動物
這是我點擊超鏈接和視頻標簽時的代碼。 我從數據庫動態加載視頻。 屬性“pos”以秒為單位告訴玩家必須尋求玩游戲的時間。
<video id="VideoContainer" controls="controls" style="width:500px;height:320px" preload="auto">
<source id="VideoData" src=@Model.IntroVideoPath type="video/mp4" />
Your browser does not support the video tag.
<a onclick="navVideo('@items.FileName','@items.StartSec');">@items.DisplayText</a>
function navVideo(fileName, pos) {
//Get Player and the source
var player = document.getElementById('VideoContainer');
var mp4Vid = document.getElementById('VideoData');
var mp4CurVid = $(mp4Vid).attr('src');
//Reload the player only if the file name changes
if (mp4CurVid != fileName) {
$(mp4Vid).attr('src', fileName);
player.load();
player.play();
if (pos != 0) {
setTimeout(function () {
player.currentTime = pos;
player.play();
}, 1000);
}
}
else {
player.pause();
player.currentTime = pos;
player.play();
}
問題在於該 MP4 文件的編碼技術。 我使用不同的設置(Mp4 的隨機設置選項)進行編碼,最后讓它在沒有緩沖區的情況下工作。
你可以使用這個http://videojs.com/來讓它工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.