O'Reilly logo

.NET Framework 4.5 Expert Programming Cookbook by A.P. Rajshekhar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Playing videos using MediaElement

The MediaElement control provides an easy way to play videos in WPF applications. Essentially, MediaElement wraps Windows Media Player. So any video that Windows Media Player can play, MediaElement can also play.

In this recipe we will use MediaElement to create a simple video player with four basic functionalities: load, play, pause, and stop.

How to do it...

  1. Launch Visual Studio 2012. Create a new project of type WPF Application. Name it WpfMediaPlayer.
  2. Add a reference to System.Window.Forms.
  3. Open MainWindow.xaml. Switch to design mode.
  4. Design it so that it looks similar to the following screenshot:
    How to do it...
  5. Name the controls ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required