Media Play To sample


Windows Runtime
Audio and video
Windows RT
en-US
3/19/2013

This sample demonstrates the Play To API.

The Play To sample demonstrates how you can expand your media application and add the capability to stream video, audio, and images to other devices on your local network. For example, a user that is watching a video in your application can stream that video to their TV for everyone in the room to view. This sample demonstrates how to stream a media file and how to stream pictures as a slide show.

You can use Windows Media Player as a Play To target device. To do this, open Windows Media Player on a separate computer, and then expand the Stream menu and select "Allow remote control of my Player". You can then add Windows Media Player on the other computer as a Digital media renderer in the Devices and Printers control panel.

If you use the code from the C# version of this sample in your own app, please be aware of the following known issues:

Known issue Workaround
Callback handlers for the MediaElement element cannot reference the UI thread directly. If you attempt to reference a MediaElement element directly, you will encounter an RPC_E_WRONG_THREAD exception for invoking a call to the element on the wrong thread. Implement a dispatcher to handle RPC calls for the MediaElement callback handler as seen in this example from ScenarioOutput1.xaml.cs.
C#
void receiver_VolumeChangeRequested(Windows.Media.PlayTo.PlayToReceiver sender,
                                    VolumeChangeRequestedEventArgs args)
{
    PlayToReceiver.Dispatcher.Helper.BeginInvoke(() =>
    {
        if (dmrVideo != null)
        {
            dmrVideo.Volume = args.Volume;
        }
    });
}

To obtain an evaluation copy of Windows 8, go to Windows 8.

To obtain an evaluation copy of Microsoft Visual Studio 2012, go to Visual Studio 2012.

Related topics

Roadmaps
Adding multimedia
Designing UX for apps
Roadmap for apps using C# and Visual Basic
Roadmap for apps using C++
Roadmap for apps using JavaScript
Windows 8 app samples
Tasks
Quickstart: Using Play To in applications (JavaScript)
Quickstart: Using Play To in applications (C#)
Reference
Windows.Media.PlayTo

Operating system requirements

Client
Windows 8
Server
Windows Server 2012

Build the sample

  1. Start Visual Studio 2012 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Microsoft Visual Studio Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.