views:

203

answers:

1

Hi. 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_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>
+1  A: 

Did you try:

$f("player", "global/js/flowplayer/flowplayer-3.1.5.swf", { 
  clip: {
    onStart: function(clip) {
      alert('poop');
    }
  }
}); 
Jan Willem B
Thanks, Jan. I'd tried that before with no luck. Not sure why it's not working.
Alex
the clip: part is where it is different from your sourcecode. Did you notice? Just to be sure :)
Jan Willem B
Hi, Jan. Thanks again. Yes, tried the above code and no luck. Please note the update to the original question above: I've added the generated Flowplayer code using Firebug. Also tried "vid" and "vid_api" as the player ID and still no luck.
Alex