
Websites often need to play multiple videos in succession. In order to do so, publishers use what’s known as a playlist. The JW Player comes built with a Flash playlist, which you can configure to suit your needs.
In this tutorial you will learn how to:
Select the type of playlist format you plan to use. The following playlist formats are supported by the JW Player for Flash:
In this tutorial, we are going to work with a XSPF feed.
After you have selected what type of playlist you want to use, you need to populate it with videos.
Below, you will find a properly formatted example of a playlist.
<playlist version="1" xmlns="http://xspf.org/ns/0/">
<title>Example XSPF playlist for the JW Player</title>
<info>http://developer.longtailvideo.com/trac</info>
<tracklist>
<track>
<title>The First Video</title>
<creator>LongTail Video</creator>
<info>http://www.longtailvideo.com/</info>
<annotation>The first video that will appear in the playlist.</annotation>
<location>http://developer.longtailvideo.com/files/firstvideo.flv</location>
</track>
<track>
<title>The Second Video</title>
<creator>LongTail Video</creator>
<info>http://www.longtailvideo.com/</info>
<annotation>The second video that will appear in the playlist.</annotation>
<location>http://developer.longtailvideo.com/files/secondvideo.flv</location>
</track>
<track>
<title>The Third Video</title>
<creator>LongTail Video</creator>
<info>http://www.longtailvideo.com/</info>
<annotation>The third video that will appear in the playlist.</annotation>
<location>http://developer.longtailvideo.com/files/thirdvideo.flv</location>
</track>
</tracklist>
</playlist>
You will notice that each piece of content in your playlist is represented by the track element, expressed as <track>. Each track element contains additional elements that define the metadata for each piece of content. They are:
In order to enable all JW Player file properties for all feed formats, the 4.4 player introduced a jwplayer namespace. By inserting this into your feed, file properties that are not supported by the feed format itself (such as the provider or duration in an RSS feed) can be amended without breaking validation. Any FlashVar can be inserted into the playlist letting you customize the player on a per-playlist-item basis. However, some configuration options are loaded by the player only once.
Using our example from before:
<playlist version="1" xmlns="http://xspf.org/ns/0/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/wiki/FlashFormats">
<title>Example XSPF playlist for the JW Player</title>
<info>http://developer.longtailvideo.com/trac</info>
<tracklist>
<track>
<title>The First Video</title>
<creator>LongTail Video</creator>
<info>http://www.longtailvideo.com/</info>
<annotation>The first video that will appear in the playlist.</annotation>
<location>http://developer.longtailvideo.com/files/firstvideo.flv</location>
<jwplayer:author>the Peach Open Movie Project</jwplayer:author>
<jwplayer:provider>http</jwplayer:provider>
<jwplayer:duration>34</jwplayer:duration>
</track>
...
</tracklist>
</playlist>
Pay attention to the top-level tag, which describes the JW Player namespace with the xmlns attribute. This must be available in order to ensure that the feed remains valid.
You can mix jwplayer elements with both the regular elements of a feed and elements from other extensions (mrss/itunes).
The JW Player's playlist support is highly configurable: you can edit the appearance of your playlist, how it is attached to the player, and how the player behaves when reading the playlist. To help you do this the JW Player makes several FlashVars available to you. They are as follows:
For more information about how to embed Flash, see our Embedding Flash tutorial.
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='300' height='300' id='player1' name='player1'>
<param name='movie' value='player.swf'>
<param name='allowfullscreen' value='true'>
<param name='allowscriptaccess' value='always'>
<param name='flashvars' value='file=playlist.xml'>
<embed id='player1'
name='player1'
src='player.swf'
width='300'
height='300'
allowscriptaccess='always'
allowfullscreen='true'
flashvars="file=playlist.xml&playlist=bottom&playlistsize=180"
/>
</object>
<script type="text/javascript">
var so = new SWFObject('player.swf','flashContent','300','250','9');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addParam('bgcolor','#FFFFFF');
so.addParam('flashvars','file=playlist.xml&playlist=bottom&playlistsize=180');
so.write('flashbanner');
</script>
<script type="text/javascript">
var flashvars = {
'file': 'playlist.xml',
'playlist': 'bottom',
'playlistsize': '180'
};
var params = {
'allowfullscreen': 'true',
'allowscriptaccess': 'always',
'bgcolor': '#ffffff'
};
var attributes = {
'id': 'player1',
'name': 'player1'
};
swfobject.embedSWF('player.swf', 'flashContent', '300', '250', '9', 'false', flashvars, params, attributes);
</script>