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:

mediaType media
Audio The URL of the audio to play. Local file paths require escaped (double) backslashes.
DVD A string in the following format: DVD://path [?address]. For more information, see the Remarks section.
Radio A 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.
TV A string representing the call sign of the service to play, or a service ID retrieved by the Lineup or ScheduleEvent class.
Video The 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 is optional and 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 address is not specified, Windows Media Center starts playing the DVD from the beginning if it has not been played before, or resumes playback from the last playback position.

The examples in the following table show several ways to specify the mediaLocation parameter, where F is the DVD drive:

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

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