Working with Audio and Video


You can play sound effects in MCML by using a PlaySound action in a custom rule. In the following example, a sound is played in response to a click event.

    <!-- Watch for the click event. -->
    <Changed Source="[Charge.Invoked]">

            <!-- Play a sound. -->
            <PlaySound Sound="file://Launch.wav"/>


To display video in MCML, use the Video view item. The Video element does not provide a way to start, stop, or change the content that is playing, so to control video you must use the Windows Media Center API.

The current video that is playing is displayed within a Video view item, although the size of the view item does not affect the size of the video. When configuring the layout, set a minimum size or use anchor points for Form or Anchor layout.

You can capture a video click event (the user clicks or selects a view port) by placing a Video view item within a UI that has implemented a ClickHandler, with HandlerStage set to "Routed" (if you want to intercept it before the video is displayed full screen).

You can create effects simply by displaying multiple view items within a UI. The first item has the highest z-order; that is, the first item is displayed on top of the next item, and so forth.

The following example shows a simple UI to display a video file in full screen.

<Mcml xmlns=""
      xmlns:addin="assembly://Microsoft.MediaCenter/Microsoft.MediaCenter.Hosting" >

  <UI Name="VideoPlayback">

      <cor:String Name="VideoPath" String="C:\Resources\Video01.wmv"/>

      <addin:AddInHost Name="AddInHost"/>

          <Invoke Target="[AddInHost.MediaCenterEnvironment.PlayMedia]"
                  mediaType="Video" media="[VideoPath]" addToQueue="false"/>
          <Invoke Target="[AddInHost.MediaCenterEnvironment.MediaExperience.GoToFullScreen]"/>

          <Video MinimumSize="400,300" />


Sample Explorer

  • View Items – Video > Video
  • MediaCenterEnvironment > PlayMedia - Audio
  • MediaCenterEnvironment > PlayMedia - Video
  • MediaExperience > all samples

See Also