Partager via


Retrieving a Requested Playlist Object

When the client connects and requests a playlist, the server creates a playlist object that reflects the structure of the playlist. The following examples illustrate how to use the RequestedPlaylist property on the IWMSPlayer interface to retrieve the playlist object.

Visual Basic .NET Example

Imports Microsoft.WindowsMediaServices.Interop
Imports interop_msxml

Private Sub ReqPlaylist()

  ' Declare objects.
  Dim Server As WMSServer
  Dim Player As IWMSPlayer
  Dim Playlist As IWMSPlaylist

  Try
    ' Create a WMSServer object.
    Server = CreateObject("wmsserver.server")

    ' Retrieve the first connected player in the IWMSPlayers 
    ' collection, and retrieve the playlist requested by the client.
    Player = Server.Players.Item(0)
    Playlist = Player.RequestedPlaylist

  Catch Err As Exception
    ' TODO: Exception handler goes here.

  Finally
    ' TODO: Clean-up code goes here.

  End Try

End Sub

C# Example

using Microsoft.WindowsMediaServices.Interop;
using interop_msxml;

// Declare variables.
WMSServer server;
IWMSPlayer player;
IWMSPlaylist playlist;

// Create the server object.
server = new WMSServerClass();

// Retrieve the first connected player in the IWMSPlayers 
// collection and retrieve the playlist requested by the client.
try
{
  player = server.Players[0];
  playlist = player.RequestedPlaylist;
}

catch (Exception)
{
  // TODO: Exception handler goes here.
}

finally
{
  // TODO: Clean-up code goes here.
}

C++ Example

// Include header files.
#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR and CComVariant.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer      *pServer;
IWMSPlayers     *pPlayers;
IWMSPlayer      *pPlayer;
IWMSPlaylist    *pPlaylist;
CComVariant     varIndex;
HRESULT         hr;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
if (FAILED(hr))goto EXIT;

hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr))goto EXIT;
    
// Retrieve a pointer to the player collection.
hr = pServer->get_Players(&pPlayers);
if (FAILED(hr))goto EXIT;

// Retrieve a pointer to the first player in the collection.
varIndex = 0;
hr = pPlayers->get_Item(varIndex, &pPlayer);
if (FAILED(hr))goto EXIT;

// Retrieve a pointer to the requested playlist.
hr = pPlayer->get_RequestedPlaylist(&pPlaylist);
if (FAILED(hr))goto EXIT;

EXIT:
// TODO: Release temporary objects and uninitialize COM.

See Also (General)

See Also (Visual Basic .NET)

See Also (C#)

See Also (C++)