Windows Media Player 11 SDK Playlists 

Windows Media Player SDK banner art

Previous Next

Playlists

The Windows Media Player 6.4 ActiveX control object model includes four methods and one property for working with Windows Media metafile playlists:

  • Player6.GetCurrentEntry
  • Player6.SetCurrentEntry
  • Player6.GetMediaParameter
  • Player6.GetMediaParameterName
  • Player6.EntryCount*.*

Together, these provide limited functionality for navigating a playlist metafile with an .asx file name extension and retrieving information about the entries contained in the playlist.

Windows Media Player 7 introduced "Media Library." The library allows users to organize their digital media content, as well as to create custom playlists that can be managed from the Player graphical user interface. The Windows Media Player 7 or later ActiveX control object model provides support for working with library playlists, as well as playlists contained in Windows Media metafiles with an .asx file name extension.

Note For security reasons, the user must grant access rights to the library before your program can manipulate its content. Access rights can only be requested and granted through the Windows Media Player 9 Series or later object model. For details about access rights, see Library Access.

The Windows Media Player 7 or later object model includes three objects for handling playlists. The PlaylistCollection object provides functionality for organizing playlists; it represents the entire collection of playlists in the user's library. The PlaylistArray object provides a way to retrieve a specific playlist from the PlaylistCollection object by using an index number; two of the PlaylistCollection object methods retrieve a PlaylistArray object. The Playlist object provides the properties and methods necessary to manipulate media items contained in a single playlist.

As an example, since each playlist in the library has a unique name, you can retrieve a playlist from the library using the PlaylistCollection.getByName method:

  

You will most frequently want to work with the current playlist. While it is possible to use several playlist objects, only one can be retrieved by the Player.currentPlaylist property at any given time: the one that Windows Media Player is processing at that moment.

When Windows Media Player 7 or later plays a Windows Media metafile with an .asx file name extension, it first creates a Playlist object. Next, it fills the object with the information from the .asx playlist, and then makes that Playlist object the current playlist. This means that you can use the properties and methods associated with the Playlist object to manipulate .asx playlists exactly as you would handle playlists in the library. For instance, to retrieve the number of entries in an .asx playlist using the version 6.4 object model, you use the Player6.EntryCount property:

  

When using the Windows Media Player 7 or later object model, you use the Playlist.count property:

  

When using the version 6.4 control, you can use the Player6.GetCurrentEntry method to retrieve the index of the current entry in an .asx playlist:

  

You can achieve the same result by using the Windows Media Player 7 or later object model in script. The following JScript example compares the current media object to each item in the playlist. When Media.isIdentical returns true, a message box displays the index of the current media item.

  

To specify the index of the current entry in an .asx playlist, you use Player6.SetCurrentEntry. Playlist entry indexes in version 6.4 start with 1, so to make the second entry in a metafile playlist the current one, use the following syntax:

  

Playlist entry indexes are zero-based in Windows Media Player 7 or later; to make the second entry in a metafile playlist the current one, when using the Windows Media Player 7 or later object model, use the following syntax:

  

The following JScript example demonstrates a function that accepts an index number as a parameter, and then makes the playlist entry that corresponds to the index the current media item:

  

Windows Media metafiles can contain custom parameter elements, which you specify by using the <PARAM> tag. When using the version 6.4 object model, you can retrieve the name of a particular parameter with the Player6.GetMediaParameterName method. The following JScript example retrieves the name of the first parameter in the first entry of an .asx playlist:

  

Similarly, you can retrieve the value associated with the parameter using Player6.GetMediaParameter:

  

The following JScript example uses the Windows Media Player 7 or later object model to retrieve the parameter name and value from the first entry in an .asx playlist:

  

You can use the PlaylistCollection.importPlaylist method to add an .asx playlist to the library. Once imported, the metafile playlist becomes a library playlist, so you can manipulate it using all the properties and methods at your disposal. The user must grant full access rights to the library for your application to be able to use the importPlaylist method.

You can use PlaylistCollection.getByName to test whether a playlist exists. This method always returns a valid PlaylistArray object. If the playlist array retrieved contains exactly one playlist, then there exists a playlist with that name in the library. Otherwise, the playlist array will contain no playlist object; this means there is no playlist in the library with the name passed as an argument to the getByName method. The following JScript example demonstrates this:

  

See Also

Previous Next