Yoda
Yoda

Reputation: 18068

How play video in Windows Phone application

How to play video on the Windows Phone telephone kept at project resources? The codec is MPEG-1 Layer 2 and the multimedia container is avi. I would like to play this file in Windows Phone Page without any controls(play, pause, stop) visible. I can convert video file to any other format if this is more convienient.

What component should I use and how to bind this component to the video and then play?

Upvotes: 0

Views: 86

Answers (1)

har07
har07

Reputation: 89285

You can use MediaElement control for displaying video without play/pause/stop controls :

<MediaElement AutoPlay="True" x:Name="mediaEl" MediaFailed="MediaEl_MediaFailed"
    Source="pathToVideoRelativeToCurrentPage.mp4"/>

Good practice when using MediaElement control is to handle MediaFailed event. Because when loading media file fails (f.e. file not found due to wrong path), ME doesn't throw exception but raise MediaFailed event instead.

List of media format supported by silverlight version of MediaElement control can be found in this MSDN post.

Upvotes: 1

Related Questions