Managing Synchronization Playlists

Windows Media Player 10 or later uses playlists to synchronize digital media files with portable devices. This section explains how to work with synchronization playlists.

The example code in this section uses two ListView controls to display information. The first ListView control (IDC_PLVIEW) displays all of the playlists in the Windows Media Player library, with synchronization playlists appearing first. Synchronization playlists for the currently selected device are marked with a check mark and are sorted in synchronization priority order. All other playlists are unchecked. The ListView control was configured for single selection. The order of playlists in the ListView control determines their synchronization priority. The checked state of an individual playlist determines whether it is a synchronization playlist for the currently selected device.

The second ListView control (IDC_MEDIAVIEW) displays the media items in the selected playlist. Two additional columns display text indicating whether the digital media file was copied to the device and, in the case of a failure, whether the copy failed because the digital media file did not fit.

The following example code shows how the ListView controls are initialized:

STDMETHODIMP CSyncSettings::InitListView()
    m_hPlView = GetDlgItem(IDC_PLVIEW);
    m_hMediaView = GetDlgItem(IDC_MEDIAVIEW); 


    // Sync playlist information.
    // Selection highlights all rows.
    // Show checkboxes.
    ListView_SetExtendedListViewStyleEx(m_hPlView, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT);
    // Add headers.
    LVCOLUMN lvc;
    ZeroMemory(&lvc, sizeof(LVCOLUMN));
    lvc.iSubItem = 0;
    lvc.pszText = _T("Sync"); = 40;
    ListView_InsertColumn(m_hPlView, lvc.iSubItem, &lvc);

    lvc.pszText = _T("Playlist Name"); = 300;
    ListView_InsertColumn(m_hPlView, lvc.iSubItem, &lvc); 

    // Media information.
    // Selection highlights all rows.
    ListView_SetExtendedListViewStyleEx(m_hMediaView, 0, LVS_EX_FULLROWSELECT);

    // Add headers
    ZeroMemory(&lvc, sizeof(LVCOLUMN));
    lvc.iSubItem = 0;
    lvc.pszText = _T("Media name"); = 150;
    ListView_InsertColumn(m_hMediaView, lvc.iSubItem, &lvc);

    lvc.pszText = _T("On Device"); = 69;
    ListView_InsertColumn(m_hMediaView, lvc.iSubItem, &lvc);  

    lvc.pszText = _T("Fit?"); = 40;
    ListView_InsertColumn(m_hMediaView, lvc.iSubItem, &lvc);  
    return S_OK;

The following array of strings contains the names of the synchronization attributes used in the examples:

static const TCHAR *g_szSyncAttributeNames[17] = {
        _T("Not used"), // Do not access this one.

The following member variable contains a playlist containing all playlists in the Windows Media Player library. Each playlist is represented as a media item.

CComPtr<IWMPPlaylist> m_spPlaylist;

The following sections provide example code:

Related topics

Working with Portable Devices