WP7 SDK Nifty Classes

My tally for Windows Phone 7 applications isn't too high. Not compared to some of my friends at Three Red Cubes. In my defense though, I've been working on several MVC projects that are pure fun to work with. But to close the gap, I got down and dirty and wrote Laaalallaaa Share (?share)

The application is really simple but it uses a very interesting .Net namespace Microsoft.Xna.Framework.Media and some classes from Microsoft.Phone.Tasks

MediaPlayer:

This static class exposes a number of methods and properties to access the media player (duh!) and the library.

For example I used the properties in MediaPlayer.Queue.ActiveSong to find the details of the current song being played. MediaPlayer.State holds the status of the media player, use it to find the state of the player.

This class also exposes a number of events such as ActiveSongChanged or MediaStateChanged that lets the application know if the current song has changed or if the song has stopped/started playing. Handy stuff.

MediaPlayerLauncher

Launchers and Choosers in the Windows Phone world give us developers access to a number of operating system and user functionalities.

The MediaPlayerLauncher is used to "start the media player and play the media file you specify." But you don't necessarily have to play a file, you can just take the user to the music player, like I did. Read more about this class

ShareStatusTask

As of Windows Phone 7 Mango (Windows Phone OS 7.1), this class exists in the Microsoft.Phone.Tasks namespace. This class launches "a dialog that enables the user to share a status message on the social networks of their choice."

By setting the Status property and calling Show you could get to the People Hub's "Post a Message" page and let the user post away. Read more about how to use this task.

There you are, three nifty little classes that do really cool things that I hope you'll use in your next application. Say... when you sign up for The Developer Movement and win a bunch of expensive cool gadgets or Imagine Cup and win a lot of money!

This post also appears in Code Trek.

Kowsheek Mahmood | MSP