IWMSActiveMedia::get_Live
.gif)
| Previous | Next |
IWMSActiveMedia::get_Live
The get_Live method retrieves a Boolean value that indicates whether the media element originates from a live source.
Syntax
HRESULT get_Live( VARIANT_BOOL* pVal );
Parameters
pVal
[out] Pointer to a VARIANT_BOOL that indicates whether the media element is live.
Return Values
If the method succeeds, it returns S_OK. If it fails, it returns an HRESULT error code.
| Return code | Number | Description |
| E_POINTER | 0x80004003 | pVal is a NULL pointer argument. |
Remarks
Client versions later than Windows Media Player for Windows XP will return this property correctly; however older client versions will always report content as being live.
Example Code
#include <windows.h>
#include <atlbase.h> // Includes CComVariant.
#include "wmsserver.h"
// Declare variables and interfaces.
HRESULT hr;
IWMSServer *pServer;
IWMSPlayers *pPlayers;
IWMSPlayer *pPlayer;
IWMSPlaylist *pPlaylist;
IWMSActiveMedia *pActiveMedia;
CComVariant varIndex;
VARIANT_BOOL bLive;
long lCount;
// Initialize the COM library and retrieve a pointer
// to the IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
NULL,
CLSCTX_ALL,
IID_IWMSServer,
(void **)&pServer);
if (FAILED(hr)) goto EXIT;
// Retrieve a pointer to the IWMSPlayers interface
// and retrieve the number of connected players.
hr = pServer->get_Players(&pPlayers);
if (FAILED(hr)) goto EXIT;
hr = pPlayers->get_Count(&lCount);
if (FAILED(hr)) goto EXIT;
// If players are connected, retrieve a pointer to
// an IWMSPlayer interface containing the first player.
if (lCount > 0)
{
varIndex = 0;
hr = pPlayers->get_Item(varIndex, &pPlayer);
if (FAILED(hr)) goto EXIT;
}
// Retrieve the playlist for the player.
// NOTE: A valid playlist file is not always returned. This may be
// the case, for example, if the user requested a specific content
// file or if a broadcast publishing point is being used.
hr = pPlayer->get_RequestedPlaylist(&pPlaylist);
if (FAILED(hr)) goto EXIT;
if (pPlaylist != NULL)
{
// Retrieve a pointer to the IWMSActiveMedia interface.
hr = pPlaylist->get_CurrentMediaInformation(&pActiveMedia);
if (FAILED(hr)) goto EXIT;
// Retrieve a Boolean value indicating whether the stream is live.
hr = pActiveMedia->get_Live(&bLive);
if (FAILED(hr)) goto EXIT;
if (bLive == VARIANT_TRUE)
// TODO: Handle any live stream-specific tasks here.
}
EXIT:
// TODO: Release temporary COM objects and uninitialize COM.
Requirements
Header: wmsserver.h.
Library: WMSServerTypeLib.dll.
Platform: Windows Server 2003 family, Windows Server 2008 family.
See Also
| Previous | Next |