Streaming media to devices using Play To (XAML)
[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]
Play To enables users to easily stream audio, video, or images from their computer to networked devices.
Roadmap: How does this topic relate to others? See:
- Roadmap for Windows Runtime apps using C# or Visual Basic
- Roadmap for Windows Runtime apps using C++
You can use Play To to enable users to easily stream audio, video, or images from their computer to devices in their home network. For example, a user who is watching a video in your application can stream that video to their TV for everyone in the room to view.
Play To streams audio, video, or images to a certified Play To receiver.
Play To is part of the Devices charm. For applications that contain audio, video, or images, the user opens the Devices charm. The user is then presented with devices from their home network to which they can stream the media content.
Using Play To in your application
You can use Play To to stream the images, audio, or video in your application, by implementing the Play To contract. To implement the Play To contract in your application, register for the SourceRequested event. Then get a reference to the current PlayToManager by calling the GetForCurrentView method. You can then call addEventHandler on the PlayToManager to associate your event handler with the SourceRequested event. In your event handler, pass the media element from your application to the SetSource method of the PlayToSourceRequestedEventArgs object that was passed to the event handler.
When a user selects a Play To target from the Devices charm, Play To will raise the SourceRequested event. Play To then streams the media element passed to the SetSource method to the target device selected by the user.
When Play To streams media from your application to a target device, Play To will continue to stream the media even if your application is moved to the background while another application is active. For more information, see Launching, resuming, and multitasking.
Guidelines for using Play To in an application
If your application enables users to view video or images, or to listen to audio, be sure to include Play To functionality in your application to also enable the user to stream the media to a remote device.
Ensure that you enable the Devices charm in your application wherever you have audio, video, or image content available to the user.
Ensure that users can continue to navigate through your application once they have begun streaming media to a remote device by using Play To. To keep media streaming, you must ensure that the media element in your application remains within scope.
Because Play To is part of the Windows UI, do not require users to navigate to a specific page or screen of your application in order to use Play To.