Chapter 15. Building a media player

 

This chapter covers

  • Using the MediaPlayerLauncher
  • Building a media player
  • Working with local and web media

One of the more popular uses for a mobile phone is as a media player. Developers have a variety of different options when building applications that play media. In chapter 9 we showed you how to integrate with the Music + Videos Hub and to make use of the XNA Framework and the BackgroundAudioPlayer to play audio. In this chapter we look at the MediaPlayerLauncher and the XAML MediaElement control that can be used to play both audio and video from inside an application.

Both of these media players can play media files that are in the install or local storage folders and download and play media files located on the internet. With both players you can create a full-featured media player with a few lines of code. In this chapter you’ll see how to launch the built-in Media Player application, providing your users with the common experience they’re familiar with. Next, you’ll implement a basic media player by using the MediaElement control, which gives you programmatic control over the experience that’s not available when using the MediaPlayerLauncher. In this example you’ll learn how to render different media types supported by Windows Phone and how to control the playback. The media containers supported by Windows Phone through the MediaElement control include WAV, MP3, WMA, 3GP, 3G2, MP4, M4A, WMV, and M4V.

15.1. Playing media with the MediaPlayerLauncher

15.2. Building a media player with MediaElement

15.3. Summary