How to create and manage a playlist |
|
Supported standard playlist formats are the following:
• | M3U |
• | PLS |
• | WPL |
Proprietary playlist formats are the following:
• | PDJ |
A normal playlist can be created from scratch using the PlayListCreate method.
If a playlist already exists on your PC, you can load it into a player through the PlayListLoad method; a call to this method won't return control to the container application until the playlist has been loaded completely so, if the playlist should be very long, it could block your user interface for a while; for this reason there is the possibility to call the PlayListLoadSync method which will perform playlist analysis and loading in a separate thread: the container application is informed about the loading advancement through the CallbackForPlayersEvents delegate which is invoked with the nEvent parameter set to EV_PLAYLIST_LOAD_STARTED, EV_PLAYLIST_LOAD_PERC and EV_PLAYLIST_LOAD_DONE.
A playlist can also be created directly from a CD using the PlayListLoadFromCd method that will automatically load all the available CD audio tracks.
At runtime, when an item of the playlist is loaded into the player, the CallbackForPlayersEvents delegate is invoked with the nEvent parameter set to
EV_PLAYLIST_SOUND_LOADED. If the loading session fails, for example because the format of the item is not supported or because the item is not available inside the system, the CallbackForPlayersEvents delegate is invoked with the nEvent parameter set to EV_PLAYLIST_SOUND_LOAD_FAILED.
A playlist, loaded from disk or created from scratch, can be modified through the following methods:
PlayListAddItem to add one or more new songs to the playlist
PlayListAddItemWithTag to add a new song to the playlist with an associated tag string: this tag string will be reported when the CallbackForPlayersEvents delegate is invoked with the nEvent parameter set to EV_PLAYLIST_SOUND_LOADED when the item is loaded into the player at runtime.
PlayListRemoveItem to remove a song from the playlist
PlayListMoveItem to change the position of a song
PlayListGetCount to retrieve the number of songs currently in the playlist
PlayListGetItemString to retrieve information about a chosen song
PlayListSetLoop to make the playlist loop when it has been executed completely
PlayListSetShuffle to set a random playing order of the playlist songs: when the "shuffle" option is selected, you may know which item is currently being rendered through the PlayListCurrIndexGet method, which will be the next item to be rendered though the PlayListNextIndexGet method and the full ordered table of indexes that will be executed through the PlayListExecOrderTableGet method. You may modify the next index of the item to be executed through the PlayListNextIndexSet method.
Once the playlist has been filled you can save it on your PC using the PlayListSave method.
The playlist can be executed using the following methods:
PlayListExecute to start the playlist execution from the beginning
PlayListExecNext to execute the next song
PlayListExecPrev to execute the previous song
PlayListExecAt to execute the song at the given position
PlayListStop to stop the automatic execution of the playlist
When the "shuffle" option is selected, a new shuffle is performed any time the playlist is completed or when PlayListExecAt or PlayListExecute methods are invoked.
Playlists can also be used, through the embedded Automatic Fader, for cross-fading between two players: for details about using the Automatic Fader refer to the How to use the Automatic Fader section.
A playlist file can consist of both audio tracks and/or video clips: based upon the file extension, the control will decide if the file to be loaded is an audio track or a video clip; for formats like MP4 and WMV, which can be supported in both ways but which are considered as video clips by default, you can use the AudioExtensionAdd method in order to load them as simple audio tracks and to ignore the contained video stream.
Starting from version 5.0 of the component, MultiMedia Soft has introduced a new proprietary playlist format named PDJ; this new format allows adding volume points automation and cue points management to playlist's elements and also the use of encrypted sounds generated using the CryptSound™ application; for details about the use of this new format refer to the How to manage Volume Automation tutorial.
In case you should need adding volume automation features to your playlist, you could use the PlayListCreatEx method passing PLAYLIST_AUTOMATION_MODE to the nMode parameter. When the playlist has been loaded with volume automation enabled, the following methods can be used to modify contained items:
PlayListItemVolAutomPointAdd to add a new volume automation point to an existing item
PlayListItemVolAutomSetMixPos to modify mixing positions of an existing item
PlayListItemVolAutomPointRemove to remove a volume automation point from an existing item
PlayListItemCuePointAdd to add a new cue point to an existing item
PlayListItemCuePointRemove to remove a cue point from an existing item
When using the PDJ format with one single player, the availability of mixing points, cue points and volume automation points is not mandatory: you can in any case use this format as other common playlist formats as seen below (note that, respect to usage with volume automation attributes, the tag FaderPlayList is in this case changed into NormalPlayList):
<?xml version="1.0"?>
<NormalPlayList>
<PlayListItems>
<Item pathname="C:\sounds\drumtrik01_120bpm.wav" />
<Item pathname="C:\sounds\drumtrik17_86bpm.wav" />
<Item pathname="C:\sounds\drumtrik14_132bpm.wav" />
</PlayListItems>
</NormalPlayList>
In a similar way, in case you should need using encrypted sounds with a single player, you could have something like this:
<?xml version="1.0"?>
<NormalPlayList>
<PlayListItems>
<Item pathname="C:\sounds\drumtrik01_120bpm.bxx" DecryptKey="20041C2645684A1BAA30237EF02E7F2A"/>
<Item pathname="C:\sounds\drumtrik17_86bpm.bxx" DecryptKey="20041C2645684A1BAA30237EF02E7F2A"/>
<Item pathname="C:\sounds\drumtrik14_132bpm.bxx" DecryptKey="20041C2645684A1BAA30237EF02E7F2A"/>
</PlayListItems>
</NormalPlayList>
The use of the "bxx" extension for encrypted files pointed by a PDJ playlist file allows the component to recognize these files as encrypted audio files. Although not mandatory, it's always suggested the use of this extension for encrypted audio files pointed by a playlist file in PDJ format.
The PlayListItems sub-key contains a set of items, each one defined by the Item sub-key. Each Item sub-key contains the following attributes and sub-keys:
• pathname attribute: The absolute pathname of the sound file to play
• Title attribute: Optional string of text containing the title or a description of the sound file to play
• DecryptKey attribute: Optional decryption key for sound files encrypted through the CryptSound™ application
• DurationSec attribute: Duration of the song expressed in seconds. This attribute can be replaced by DurationMs if milliseconds are preferred as scale unit.
• NormalizationPeak attribute: Highest peak value of the sound file that will be used to speed up the loading of the file during playlist's execution when normalization has been enabled through the Effects.NormalizationEnable method.
• CustomTag attribute: custom string that will be reported to the container application through the pBufferUnicode parameter of the CallbackForPlayersEvents delegate, invoked with the nEvent parameter set to EV_PLAYLIST_SOUND_LOADED, when the file is loaded during playlist's execution.
Samples of use of playlists in Visual C#.NET and Visual Basic.NET can be found inside the following samples installed with the product's setup package:
- Playlists
- Fader