2013-10-29 99 views
2

我想要使用視頻作爲自動延伸至整個屏幕的背景,以這種方式,如果頁面已加載,那麼在加載內容之前,視頻將播放5秒,然後暫停並加載內容,如果用戶點擊另一個鏈接,則再次開始播放,並且在視頻結束之前用戶不會被重定向。在重定向到另一個頁面之前播放視頻

$(function() { 
var BV = new $.BigVideo(); 
BV.init(); 
BV.show('http://video-js.zencoder.com/oceans-clip.mp4'); 
}); 

我的代碼工作正常,它只是我不知道如何在重定向到另一個頁面,而無需使用中間頁

+1

作爲一個用戶,這聽起來真的* *討厭。有一個谷歌的「onBeforeUnload」事件。這將做你需要的。 –

+0

'onbeforeunload'事件將無法將用戶保留在頁面上。爲此,您必須重寫頁面上的每個鏈接才能播放視頻,然後再轉到鏈接的位置。但是,如果用戶在新窗口中打開鏈接,它會中斷,而某些類型的鏈接(JavaScript事件)將很難重寫。這將是一個很大的努力。 –

回答

1
<script type="text/javascript"> 

function vidplay() { 
    var video = document.getElementById("Video1"); 
    var button = document.getElementById("play"); 
    if (video.paused) { 
     video.play(); 
     button.textContent = "||"; 
    } else { 
     video.pause(); 
     button.textContent = ">"; 
    } 
} 

function restart() { 
    var video = document.getElementById("Video1"); 
    video.currentTime = 0; 
} 

function skip(value) { 
    var video = document.getElementById("Video1"); 
    video.currentTime += value; 
}  
</script> 

</head> 
<body>   

<video id="Video1" > 
// Replace these with your own video files. 
<source src="demo.mp4" type="video/mp4" /> 
<source src="demo.ogv" type="video/ogg" /> 
HTML5 Video is required for this example. 
<a href="demo.mp4">Download the video</a> file. 
</video> 

<div id="buttonbar"> 
<button id="restart" onclick="restart();">[]</button> 
<button id="rew" onclick="skip(-10)">&lt;&lt;</button> 
<button id="play" onclick="vidplay()">&gt;</button> 
<button id="fastFwd" onclick="skip(10)">&gt;&gt;</button> 
</div>   
1

想起以前播放的視頻,你需要這樣的事:

1
<!DOCTYPE html> 
<html> 
<body> 

<video width="320" height="240" controls="controls" preload="auto"> 
<source src="movie.mp4" type="video/mp4" /> 
<source src="movie.ogg" type="video/ogg" /> 
Your browser does not support the video tag. 
</video> 

</body> 
</html> 
相關問題