Share via


Scripting for Media Playback

The MediaCenter object provides methods called PlayMedia and PlayMediaEx that enable your HTML application to play media content, including TV, video, DVD, audio, and radio. The Play Media page (PlayMedia.htm) included with the sample HTML pages contains JScript and HTML code that you can use as a template for playing media content in your own HTML application. This page contains code to show or hide the view ports and to play a sample video file. The syntax for playing the sample file is as follows:

window.external.MediaCenter.PlayMedia(2, strUrl)

The first argument, the number 2, indicates the type of media (video); the second argument, strUrl, is a variable for the media file's URL. The second argument must specify an absolute path to your media file, not a relative path. For example, a value such as "videos/myVideo.wmv" is not supported, but a value such as "https://www.contoso.com/videos/myVideo.htm" is supported. The sample Play Media page contains an example of a workaround if you need to use a relative path. It contains an anchor that links to the video file, using a relative path for the href attribute. The page accesses the href attribute of the anchor to return the full path, and passes the path as an argument to the MediaCenter.PlayMedia method.

Note   It is recommended that you use the mms:// protocol in URLs rather than the mmst:// protocol (hard-coded TCP sourcing) or the 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.

See Also