Creating a Playlist on the Device

The Windows Media Device Manager SDK provides the means for an MTP application to create a playlist on a device. This type of playlist is called an abstract playlist, because the file created on the device contains no media data, but only metadata, which holds the links to media files in the playlist.

Other abstract items that can be created on the device include albums (essentially playlists with extra properties such as cover art), contacts, and messages.

To create a playlist

  1. Acquire an IWMDMDevice3 interface to the target device.
  2. Call IWMDMDevice3::GetProperty to obtain the g_wszWMDMFormatsSupported property.
  3. If no playlist formats are supported, disallow sending playlists to the device, and skip the following steps. Otherwise, choose the device-supported format code that matches most closely the intended object type. The generic WMDM_FORMATCODE_ABSTRACTAUDIOVIDEOPLAYLIST and WMDM_FORMATCODE_ABSTRACTAUDIOLAYLIST format codes are the most commonly supported.
  4. Obtain an IWMDMStorage3 interface for the storage (the root or a folder) where you want to create the object. Some devices work best if the playlist object is placed in a top level folder named "Playlists".
  5. Create an empty metadata object by using IWMDMStorage3::CreateEmptyMetadataObject.
  6. Using the IWMDMMetaData interface obtained in the previous step, call IWMDMMetaData::AddItem to add your chosen format code (from step 3) to the storage metadata properties.
  7. Obtain the IWMDMStorageControl3 interface from the IWMDMStorage3 interface.
  8. Call IWMDMStorageControl3::Insert3 to insert a new playlist file in the selected storage. This file contains the metadata represented by the IWMDMMetaData interface you created in step 5 and passed to Insert3. The method returns an IWMDMStorage interface for the playlist file; you can query for the IWMDMStorage4 interface.
  9. Call IWMDMStorage4::SetReferences to create references to the IWMDMStorage interfaces of the media files in the playlist.

For example code, see the _OnCreatePlaylist function in the Sample Desktop Application.

Note

The Microsoft-provided MTP service provider enables an application to set references in metadata. To implement playlists, your application must be communicating with an MTP device or using a custom service provider that can handle abstract objects. The CE service provider handles playlist and album objects.

 

Writing Files to the Device