MediaCenterEnvironment.PlayMedia Method

Loads a new media item into Windows Media Center as the currently playing media.

Syntax

public bool PlayMedia(
   MediaType mediaType,
   object media,
   bool addToQueue
);

Parameters

mediaType

Microsoft.MediaCenter.MediaType.  Indicates the type of the media.

media

System.Object.  Indicates the location of the media. The meaning of this parameter depends on the value of mediaType, as shown in the following table:

mediaTypemedia
AudioThe URL of the audio to play. Local file paths require escaped (double) backslashes.
DVDA string in the following format: [//<path>?] [<address>]. For more information, see the Remarks section.
RadioA string in the following format: [band:nn.n] or [band:nn,n], depending on the locale. For example, "fm:103.1" or "fm:103,1". For band, only FM is currently supported.
TVA string representing the call sign of the service to play, or a service ID retrieved by the Lineup or ScheduleEvent class.
VideoThe URL of the video or recorded TV file to play. Local file paths require escaped (double) backslashes.

addToQueue

System.Boolean.  If true, the media is added to the queue and is played in turn. If false, the media immediately begins playing, preempting the currently playing media, if any. This parameter is valid only when mediaType is set to Audio; otherwise, it is ignored.

Return Value

System.Boolean. It is true if the media was loaded, and false otherwise.

Remarks

If the specified media type is DVD, media is a string in the following format:

DVD:[//<path>?] [<address>]

where <path> specifies the location of the DVD, in the following format:

<unc_path> | <drive_letter>:/<directory_path>

and <address> specifies the start and end points within the DVD, in the following format:

<title> | <title>/<chapter>[-<end_chapter>] | <title>/<time>[-<end_time>]

The <title> value identifies a title within the DVD, in the following format:

[digit] digit

The <chapter> and <end chapter> values identify the first and last chapters to play within the specified title, in the following format:

[ [digit] digit] digit

The <time> and <end time> values identify the start and end points, in the following format:

[<hours>:] [<minutes>:] [<seconds>:] <frames>

The <hours>, <minutes>, <seconds>, and <frames> values are specified using the following format:

[digit | 0]  digit

If the <path> is not specified, Windows Media Center searches for and plays the first DVD it finds. If the <address> is not specified, Windows Media Center starts playing the DVD from the beginning.

The examples in the following table show several ways to specify the mediaLocation parameter:

mediaLocationDescription
2Plays title 2 in the first DVD found.
5/13Plays chapter 13 of title 5 in the first DVD found.
7/9:05-13:23Plays from 9 seconds, 5 frames to 13 seconds, 23 frames in title 7.
//myshare/dvd?9Plays title 9 from the DVD-Video volume stored in the dvd directory of myshare.
//f:/video_tsPlays the DVD-Video volume in the video_ts directory of drive F.
DVD://c:/dvdstorage/mydvd/video_ts?5/13Plays the DVD in c:\dvdstorage\mydvd\ at chapter 13 of title 5.

FM radio tuning is subject to many regional restrictions as to which frequencies can be tuned to and which decimal point character is allowed. You will need to test your web application thoroughly to be sure that this method succeeds for the stations and regions in which you intend it to be used.

Be sure to unescape your URL if it contains slashes that could be read as escape characters. If you were to assign your URL as the value for the variable myURL, the syntax to unescape would be: myUrl = unescape(myUrl).

Requirements

Reference: Microsoft.MediaCenter

Namespace: Microsoft.MediaCenter

Assembly: Microsoft.MediaCenter.dll

Platform: Windows Vista Ultimate, Windows Vista Home Premium, and later

See Also

Page view tracker