我正在使用Flowplayer Flash 视频播放器在AnythingSlider中播放 MP4 视频。我需要检测用户何时单击视频上的开始按钮,以便停止幻灯片并允许用户查看视频。我尝试使用此代码只是为了获得一个警告框,但它没有做任何事情(代码位于页面末尾,在结束</body>
标记之前):
<script type="text/javascript">
$f("player","global/js/flowplayer/flowplayer-3.1.5.swf",{
onStart: function(clip) {
alert('player started');
}
});
</script>
Flowplayer 是作为html5media 库的一部分实现的,它会自动检测浏览器是否可以处理<video>
标签;如果没有,它将下面的锚标记替换为 Flowplayer:
<video id="vid" width="372" height="209"
poster="global/vid/bbq-poster.jpg" controls preload>
<source id="videoSource" src="global/vid/BBQ_Festival.mp4"
type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
onerror="fallback(this.parentNode)" ></source>
<a
href="global/vid/BBQ_Festival.mp4"
style="display:block;width:372px;height:209px; padding-left:5px; "
id="player">
</a>
</video>
因此 $f() 函数调用位于页面末尾的 JavaScript 块中,以使播放器有机会正确加载。我究竟做错了什么?谢谢。
更新:这是生成的 HTML,如 Firebug 所示;尝试使用播放器的“vid”ID,但仍然没有运气。
<object width="100%" height="100%" type="application/x-shockwave-flash"
data="http://html5media.googlecode.com/svn/trunk/src/flowplayer.swf"
id="vid_api">
<param value="true" name="allowfullscreen">
<param value="opaque" name="wmode">
<param value="always" name="allowscriptaccess">
<param value="high" name="quality">
<param value="false" name="cachebusting">
<param value="#000000" name="bgcolor">
<param value="config={"play":null,"playlist":[{"url":"http://localhost/cms/global/vid/poster.jpg",
"scaling":"fit","fadeInSpeed":0,"fadeOutSpeed":0},
{"url":"http://localhost/cms/global/vid/BBQ_Festival.mp4",
"autoPlay":false,"autoBuffering":true,"scaling":"fit",
"fadeInSpeed":0,"fadeOutSpeed":0}],
"clip":{"scaling":"fit","fadeInSpeed":0,"fadeOutSpeed":0},
"plugins":{"controls":{"url":"http://html5media.googlecode.com/svn/trunk/src/flowplayer.controls.swf",
"fullscreen":false,"autoHide":"always"}},
"playerId":"vid"}" name="flashvars"></object>