#8 – Audio and Video
July 20, 2010 Leave a comment
WPF makes it very easy to play audio or video content in your application. You can play any media type supported by Windows Media Player including audio formats like WAV and MP3 or video formats like AVI, WMV, and MPG.
You play audio and video by including a media UI element directly in your XAML. This allows rendering and playing video on a wide variety of user controls. Here’s an example of a video playing on the surface of a Button.
<Button Height="258" HorizontalAlignment="Left" Margin="26,21,0,0" Name="button1" VerticalAlignment="Top" Width="436" > <Button.Content> <MediaElement Source="C:\Users\Public\Videos\Sample Videos\Wildlife.wmv" Stretch="Fill"/> </Button.Content> </Button>