Loads a new media item into Windows Media Center as the currently playing media.
Note This method has been deprecated.
MediaCenter.PlayMedia( mediaType, mediaLocation )
A Number (int) that indicates the media type. For more information, see the Remarks section.
A String that contains the location of the media to load. For more information, see the Remarks section.
A Boolean that indicates whether the media was loaded or not.
The value of the mediaType parameter determines the meaning and format of the mediaLocation parameter, as shown in the following table:
|0||TV||A string representing the call sign of the service to play, or a service ID retrieved by the MediaCenter.FindProgram or MediaCenter.FindService methods.|
|1||Audio||The URL of the audio to play. Local file paths require escaped (double) backslashes.|
|2||Video or Recorded TV||The URL of the video or recorded TV file to play. Local file paths require escaped (double) backslashes.|
|3||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.|
|4||DVD||A string in the following format: DVD://path [?address]. For more information, see the Remarks section.|
If the specified media type is DVD (4), mediaLocation is a string in the following format:
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:
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:
|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).
For streaming video or any other media files that take a long time to load, the Windows Media Center revolving arrow icon will be shown in the shared or custom view port to indicate that the file is loading. If neither view port is visible before the file starts playing, the arrow is not shown, so it is important to be sure that a view port is open (MediaCenter.SharedViewPort.Visible = true) before invoking the PlayMedia method. You may want to provide some additional text for user feedback to indicate that the file is loading, and so on.
Note It is recommended that you use the mms:// protocol in URLs rather than the mmst:// protocol (hard-coded TCP sourcing) or mmsu:// protocol (hard-coded UDP sourcing), which are not recommended for Windows Media Player. The mms:// protocol automatically determines whether to source the content using UDP or TCP.
Opening the view port and displaying this feedback must be done before the PlayMedia method starts searching for the file, because once it starts this process, it stops all the other processes on your page until the file starts playing. In fact, if you call a function that presents user feedback and then invokes PlayMedia, the page will not have time to update before the processes stop, so these items will not be shown until the file starts playing. The workaround for this is to use the setTimeout method to delay the start of PlayMedia slightly. Even a one-millisecond time-out appears to be adequate for this.
Platform: HTML application hosted within Windows XP Media Center Edition 2004 through Windows Vista