views:

50

answers:

3

Cross-posted on the Flowplayer forums, but no response there yet, so I hope someone here could help.

I'm having no success at all using the Playlist plugin. I've followed the examples at http://flowplayer.org/plugins/javascript/playlist.html closely, and I get the initial clip to work, but the Playlist plugin does not seem to register. The video loads and plays, so FlowPlayer is loading properly, but playlist doesn't attach any functionality to my playlist objects.

I confirmed that the playlist script is loading: I added alert("playlist!"); to the top of the flowplayer.playlist-3.0.8.js, just after the initial comment block and before the start of the function code. When I load my web page, I see the alert. I get the same results whether using the minified or normal versions of the scripts, and whether I call the flowplayer function with flowplayer() or $f(). I'm using flowplayer 3.2.3 and playlist 3.0.8.

Here's a dead-simple static page that tries to render a FlowPlayer and two clips in a gallery: FlowPlayer appears, but clicking on either of the gallery links replaces the current page with the video playing directly in the browser window, instead of keeping me on the HTML page and playing the video in the FlowPlayer instance.

If I add a config param to the FlowPlayer call and provide a default clip, then that clip plays, but again the gallery links just take me to the raw clip, rather than pushing the clip into the FlowPlayer.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
    <title>test flowplayer</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
    <script src="/_library/script/flowplayer/flowplayer-3.2.3.min.js" type="text/javascript"></script>
    <script src="/_library/script/flowplayer/flowplayer.playlist-3.0.8.min.js" type="text/javascript"></script>
</head>
<body>
    <div id="player" style="display: block; width: 776px; height: 432px;"></div>
    <div id="gallery">
        <a href="/resources/video/Empowerment_TV30_776.mp4">video 1</a>
        <a href="/resources/video/Commercial_776.mp4">video 2</a>
    </div>
    <script type="text/javascript">
        $(function () {
            $f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf")
            .playlist("gallery");
        });
    </script>
</body>
</html>

Any idea what I'm doing wrong? Any help appreciated, let me know if you need more details.

Thanks! - Val

A: 

$f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf").playlist("gallery");

maybe?

.playlist() is not a function of $(function () {})

Sirber
yep, Justin pointed that out, too. Fixed it, the JavaScript error went away, but still no Playlist functionality.
Val
A: 
$(function () {})

Is how you register an event handler for the load event. Because of this,The code within it is not executed until the load event is fired by the browser and it is possible that the plugin is not available yet.

Also, you are not following the tutorials closely. The code the have is like this

$(function() {
    // setup player without "internal" playlists
    $f("player2", "http://releases.flowplayer.org/swf/flowplayer-3.2.3.swf", {
        clip: {baseUrl: 'http://blip.tv/file/get'} 
    // use playlist plugin. again loop is true
    }).playlist("div.petrol", {loop:true});
});

Note that .playlist is called on the return of $f(), not on $(function(){...}).

Justin Johnson
I thought the same and tried that; just tried again with $(function () { $f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf").playlist("gallery"); }); -- now, I don't get JavaScript error complaining that 'playlist is not a function', but I don't get the playlist functionality either -- clicking the playlist links loads the MP4 directly into the window instead of into the Player. As for the plugin being available, I thought the script calls were synchronous, and we wouldn't get to my code until the referenced scripts in the HEAD were loaded?
Val
I fixed the question to move the .playlist() call to chain off the $f() call, and removed the references to JavaScript errors. Still not getting any playlist functionality.
Val
A: 

OK, fixed.

Many of the examples use a class on the playlist container. In examples using a class, the playlist function is passed a CSS selector -- usually something like playlist("div.gallery")

I changed my markup to use a class, changed the param to playlist() to a fully-qualified CSS selector, and it works!!!

Now, I don't want to use a class-- I have a single playlist element, so I want to use an ID. I changed the markup back to an ID:

<div id="gallery">
    <a href="video1">video1</a>
    <a href="video2">video2</a>
</div>

and changed the caller to use a CSS selector for IDs:

playlist("div#gallery");

And that works too!

Finally, I wondered if I needed to specify the element that has the playlist ID, and I don't -- I can give it just a CSS ID selector:

playlist("#gallery");

I think my problem was that with the main flowplayer script, you can address the placeholder element without the . or # qualifier, like $f("player"); instead of $f("#player");. But the Playlist plugin is more picky, and you have to use the qualifier.

All that pain for a single character!

Val