2013-10-19 58 views
1

我發現了有關如何檢測Web視頻何時結束的各種想法,但無法獲得我使用JavaScript播放視頻的方式的語法。請注意,我正在使用jwplayer的第4版。檢測視頻完成並重定向到網頁

這是使用swfobject.js和player.swf的HTML。它工作正常,但我想添加代碼,檢測視頻完成後,然後將重定向到一個Web位置使用 - window.location.href = http://www.webpage.com

任何幫助將非常感激!下面是HTML代碼的整頁:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<script type='text/javascript' src='swfobject.js'></script> 
</head> 
<body lang=EN-US bgcolor='#000000'> 

<center> 
<p id='preview'></p> 
<script type='text/javascript'> 
var so = new SWFObject('player.swf','player1','640','381','9'); 
so.addParam('allowfullscreen','true'); 
so.addParam('allowscriptaccess','always'); 
so.addParam('flashvars','&file=mymovie.m4v&bufferlength=3&autostart=true&controlbar=bottom'); 
so.write('preview'); 

</script> 
</center> 
</body> 
</html> 

回答

0

您需要使用我們的JS API - http://www.longtailvideo.com/support/jw-player/28851/javascript-api-reference

而且,使用我們的JW嵌入器(不SwfObject的) - http://www.longtailvideo.com/support/blog/15827/using-the-jw-embedder-to-embed-your-player

然後,設立遺囑看起來像這樣:

<h2>Redirecting on complete</h2> 

<div id="container">This'll be the player</div> 

<script type="text/javascript"> 
jwplayer("container").setup({ 
    file:"bunny.mp4", 
    flashplayer:"player.swf", 
    height:400, 
    width:600, 
    events:{ 
     onComplete: function() { 
      window.location = "http://www.google.com"; 
     } 
    } 
}); 
</script> 

希望幫助!