javascript - 检测视频何时结束并重定向到网页

标签 javascript flash jwplayer swfobject

我发现了关于如何检测网络视频何时结束的各种想法,但无法获得适合我使用 javascript 播放视频的方式的语法。请注意,我使用的是 jwplayer 的版本 4。

这里是使用 swfobject.js 和player.swf 的 HTML。它工作正常,但我想添加代码来检测视频何时完成,然后使用 - window.location.href = http://www.webpage.com 重定向到 Web 位置。

任何帮助将不胜感激!这是完整的 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>

最佳答案

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

并且,使用我们的 JW Embedder(不是 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>

希望有帮助!

关于javascript - 检测视频何时结束并重定向到网页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19469799/

相关文章:

javascript - 使用 JQuery 隐藏 sibling 和 parent 的 sibling 直到给定的 id

flash - scale9Grid 和位图 - 它们是否一起工作?

c# - 使用 C# 进行自动化 Flash 测试

html - 我的网站加载有问题。这是嵌入到 index.html 中的 .SWF 文件

javascript - JW播放器中视频的注释

javascript - ES6 模块是同步加载还是异步加载?

javascript - 我如何查看什么 javascript 修改了 HTML 的特定位?

Javascript 循环遍历对象集合

javascript - 在 jwplayer 5 中单击“播放”时打开新窗口

javascript - JW Player 如何取出控制栏上方的屏幕区域?