Share via


Playing and previewing audio and video (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 ]

This section contains topics on playing audio and video in your Windows Runtime app using C++, C#, or Visual Basic.

It covers how to play audio and video using the MediaElement class, share or stream media with Play To, and use effects and custom media extensions.

The control to play audio and video media is MediaElement. This is defined in the Windows.UI.Xaml.Controls namespace. The majority of the API to playback media are in Windows.Media, Windows.Media.MediaProperties, Windows.Media.PlayTo, and Windows.Media.Transcoding.

For samples that use audio and video in a Windows Runtime app using C++, C#, or Visual Basic, see the XAML media playback sample and the other samples listed in the Samples section in the Related topics below.

To see many of features in action as part of a complete media-playback sample, see Media playback, start to finish.

In this section

Topic Description

Quickstart: video and audio

Play audio and video media using a MediaElement in your Windows Runtime app using C++, C#, or Visual Basic.

How to create custom transport controls

Create custom transport controls for a MediaElement to control and manage audio and video media playback in a Windows Runtime app using C++, C#, or Visual Basic.

How to open local media files using the FileOpenPicker control

Set the media source of a MediaElement to a local audio or video file stream opened with the FileOpenPicker control.

How to select audio tracks in different languages

Use MediaElement.AudioStreamIndex and MediaElement.GetAudioStreamLanguage to change the audio to a different language track on a video.

How to enable low-latency playback

Setting the RealTimePlayback property on a MediaElement enables low-latency playback.

How to keep the display on during audio/video playback

Learn how to keep the display on while playing back local or streaming video by using the DisplayRequest class.

How to play audio in the background

To play audio in the background, declare the Audio background task and handle the SystemMediaTransportControls buttons.

Overview: Background audio for Windows Phone

You can write apps for Windows Phone 8.1 that play audio in the background. This means that even after the user has left your app by pressing the Back button or the Start button on their device, your app can continue to play audio. This article discusses the components of a background audio app and how they work together.

How to use the system media transport controls

The SystemMediaTransportControls class enables your app to use the system media transport controls provided by Windows and update the media info that is displayed.

How to enable full window rendering

Use MediaElement.IsFullWindow to enable and disable full window video rendering in a Windows Runtime app using C++, C#, or Visual Basic.

How to play media files from the network

Set the media source of a MediaElement to an audio or video file on the network.

How to resize and stretch video

Use MediaElement.Stretch to change how the video content fills the container it is in. This resizes and stretchs the video depending on the Stretch value.

Streaming media to devices using Play To

Play To enables users to easily stream audio, video, or images from their computer to networked devices.

 

Roadmaps

Roadmap for Windows Runtime apps using C# and Visual Basic

Roadmap for Windows Runtime apps using C++

Designing UX for apps

Samples

XAML media playback sample

Transcoding media sample

Media extension sample

Media Play To sample

PlayToReceiver sample

Playback manager sample

Media playback, start to finish

Reference

MediaElement

Windows.Media

Windows.Media.PlayTo

Windows.Media.Protection

Other resources

Supported audio and video formats

Optimize media resources