I'm using the Flowplayer Flash video player to play MP4 videos inside an AnythingSlider. I need to detect when the user has clicked the start button on the video so to stop the slideshow and allow the user to view the video. I've tried using this code just to get an alert box but it doesn't do anything (the code is at the end of the page, before the closing </body>
tag):
<script type="text/javascript">
$f("player","global/js/flowplayer/flowplayer-3.1.5.swf",{
onStart: function(clip) {
alert('player started');
}
});
</script>
The Flowplayer is implemented as part of the html5media library, which automatically detects whether the browser can handle the <video>
tag; if not, it replaces the anchor tag below with the 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>
So the $f() function call is in a JavaScript block at the end of the page, to give the player a chance to load correctly. What am I doing wrong? Thanks.
UPDATE: Here's the generated HTML as shown by Firebug; tried using the "vid" ID for the player and still no luck.
<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_Fes开发者_JAVA百科tival.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>
Did you try:
$f("player", "global/js/flowplayer/flowplayer-3.1.5.swf", {
clip: {
onStart: function(clip) {
alert('poop');
}
}
});
Instead of onStart, use onBufferFull. I was using onStart and sometimes the video was still buffering and onStart had already triggered. Using onBufferFull, I now that the video has buffered a minimum and it has actually started playing on the screen. If you need an event to be triggered just when the video started, make sure you save in a flag that "buffered for the 1st time gone". onBufferFull is called in chunks whenever the video has buffered a minimum (I believe the documentation says 3 seconds) to be played. Hope this helps.
精彩评论