setPlaylist

 

The playlist paramter can take the form of:

- URL to an external playlist file.
- Text-based list, delimited by newline or pipe character
- JSON
- XML
- RSS (Podcast)
- M3U (Playlist)
- PLS (Playlist)
- Javascript Array of Track Datasets
- NULL (clears the playlist)

See the "Playlists" section for details on how to create playlists.

setPlaylist(playlist, startPlaying, kind)

 

Parameters

playlist mixed

Loads a new playlist into the player.

startPlaying integer (optional)

The index of the playlist item you want to start playing.

WARNING: The "index" is the array index, which uses zero-based counting.

0 = the first item
1 = the second
2 = the third ... and so on...

For example, if set to 2, the third item in the new playlist will begin to play once the playlist is loaded.

If this value is not set, the playlist will not start playing once loaded.

kind string (optional)

Specify the kind of playlist you're sending in. This is a helper argument, as Wimpy will try and detect what kind of playlist is sent in automatically. But using this argument, you can force wimpy to handle the data you send in as a specific kind.

For example, if you're using a PHP script to feed Wimpy a playlist, Wimpy may determine that the data is different from what you actually send. When you set this "kind" argument, you can force wimpy to parse the data using the appropriate parser.

Acceptable values for this field are lowercase representations of the kind of data:

- json
- xml
- dtxt (newlineor pipe delimited text)
- txt
- m3u
- pls
- rss (podcast)
- js (javascript array)

 

Return Value

none

 

See Also

 

Examples

Example 1

Setting the playlist to an external XML playlist file.

myPlayer.setPlaylist("http://www/path/to/playlist.xml");

 

Example 2

A simple text-based playlist that is "pipe" delimited.

Starts playing the first item once the playlist is ready.

We are also setting the "kind" argument to ensure Wimpy parses the playlist properly.

NOTE: Wimpy does a pretty good job of detecting the kind of playlist you're sending in, so use the "kind" argument sparingly. This is just an example showing how the kind would look in your code and I'm not implying that you need to set the kind for all "dtxt" !

myPlayer.setPlaylist("track1.mp3|track2.mp3|track3.mp3", 1, "dtxt");
                  

Example 3

Here we're using a Javascript Array, which is a collection of Track Datasets so we can add a little more info to each item.

var myNewPlaylist = [
							{
								title	: "Track 1",
								file	: "track1.mp3",
								image	: "image1.png"
							},
							{
								title	: "Track 2",
								file	: "track2.mp3",
								image	: "image2.png"
							},
							{
								title	: "Track 3",
								file	: "track3.mp3",
								image	: "image2.png"
							}
						];

myPlayer.setPlaylist(myNewPlaylist);