Playlists

Playlists can come from two sources:

This chapter describes how to work with playlists.

For information about synchronizing playlists, see Synchronizing playlists in the chapter Synchronizing Media.

Supported playlist formats

The table below lists playlist formats supported by the MME:

Format Extension
Advanced Stream Redirector .asx
iTunes XML; see iTunes files below. .xml
MP3 URL .m3u
RMP Playlist .rmp
PLS .pls
Windows Media Player Playlist .wpl
Windows Media Audio Metafile .wax
Windows Media Video Metafile .wvx

Note: Support for other playlist formats may be added in future releases, as required.

During the file and folder discover synchronization pass, the MME adds, to the playlist table, entries for files whose extensions match supported playlist extensions listed under MME configuration file's <playlists> element. On the playlist synchronization pass, or if the client applications calls mme_playlist_sync(), the MME parses the contents of these files so that it can use the playlists as requested by the user.

For more information about playlist synchronization, see Synchronizing playlists in the chapter Synchronizing Media. For more information about the <playlists> configuration element, see Filtering synchronization by file typein the MME Configuration Guide chapter Configuring Media Synchronizations.


Note: If a playlist file is incorrectly labelled with the wrong extension, or the MME cannot parse the contents of the file, the MME will fail the playlist compilation pass.

iTunes files

The MME does not support parsing of generic iTunes database files. To use an iTunes playlist, you must:

That is, the playlist file and the files it references must be on the same mediastore outside iTunes.

For example, if you want to have an iTunes playlist Someplaylist.xml, which includes Song1.mp3 and Song2.wav, you must copy Song1.mp3 and Song2.wav to E:/music or some other location outside iTunes, then create the playlist Someplaylist.xml at the same location.

Creating track sessions from playlists

The example below shows how to create a track session from a playlist. The MME synchronizes playlists in the playlist synchronization pass, and stores them in the playlists table. If we have a playlist called “My Playlist” that was built from a SELECT statement, we can:

  1. Use the QDB function qdb_statement() to get the SELECT statement for the playlist.
  2. Pass the statement to mme_newtrksession() to create a track session with the same tracks as the playlist.
  3. Set the new track session.
  4. Play the tracks in the track session, in sequence from the beginning.
// Run the SQL statement.
qdb_statement(&db,
    "SELECT statement FROM playlists WHERE plid=%lld;",
    plid )
res = qdb_getresult( &db );

// Create a new track session from the result.
mme_newtrksession( &mmehdl, (char*)qdb_cell(res, 0, 0),
    MME_PLAYMODE_LIBRARY, &trksid );


// Set the new track session as the active track session.
mme_settrksession( &mmehdl, trksid );

// Start playing the track session from the beginning,
// passing in a fid of 0 to start from the beginning.
mme_play(&mmehdl, 0);

Excluding missing playlist files from track sessions

When it synchronizes playlists, the MME inserts in the playlistdata table a fid of 0 (zero) for any files that it cannot find. This action creates a record of files in a playlist that are not found, and causes the MME to check for the existence of these files when it performs subsequent resynchronizations.

If you build a track session using the playlistdata table, you should explicitly exclude files with a fid of 0 by adding the clause WHERE fid != 0 to track session queries made to the playlistdata table.

Combining playlists into a track session

The MME supports multiple instances of the same file ID (fid) in a track session, so you can combine playlists with duplicate fids and have the MME play all the tracks in the combined playlists.

Examining playlists

The MME includes functions that allow you to open and examine a playlist file. To open a playlist file and examine the contents of the playlist:

  1. Call mme_playlist_open() to:
  2. Call mme_playlist_items_count_get() to get the number of items in the playlist you are examining.
  3. As required, use mme_playlist_position_set() to move to a specific entry in the open playlist.
  4. Call mme_playlist_item_get() to retrieve an item from the current position in the playlist, setting the flags argument as required to convert the playlist entry into a file.
  5. Call mme_playlist_close() to close the playliste examination session and free up its buffers.

Note:
  • mme_playlist_open() can only open a playlist if a playlist synchronization (PLSS) plugin able to process the playlist is available. If no PLSS plugin for the playlist is available, this function fails.
  • The playlist examination API is very similar to the explorer API. How to use this API is described in the chapter Unsynchronized Media.

Case-sensitivity in playlists

Playlists are case-sensitive. Case-sensitivity applies to:

For example songs/my_playlist is not equivalent to songs/My_playlist. Similarly, in an M3U file songs/Dark Side of the Moon.mp3 is not equivalent to Songs/Dark Side of the moon.mp3.

Creating playlists

The MME supports user-created playlists. Please note the following about user-created playlists:

Use the following functions to create and delete playlists:

Deleting a playlist

To delete a playlist, call mme_playlist_delete().


Note: To following commands can be used with mmecli to use the user-created playlist functions:
  • Create a playlist: mmecli playlist_create msid name
  • Delete a playlist: mmecli playlist_delete plid