Must Read

Moving Picture Experts Group (MPEG)

Overview MPEG is a working group of ISO/IEC in charge of the development of standards for coded representation of digital...

The Microphone

You can use the microphone in many applications on a mobile device. For example, you can take quick audio...

Streamline Your VA Home Loan Refinance

Because of all that they do for us, veterans get special consideration when it comes to getting mortgages for...

Windows Phone 7 physical devices can store and display photos, play video and audio files, and have a built-in FM radio. To display photos and images, you can use the standard Silverlight controls such as the Image control. You can include the image file in your project and set the Build Action property to Content and the Copy to Output Directory property to Copy if newer or Copy Always, so that it is included in the XAP file that uploads to the device. You then specify the image as the source for the control. Alternatively, you can specify a remote URL for the image, and it will be downloaded and displayed
just as in a web browser. Images must be in JPEG (.jpg) or PNG (.png) format.

To display a video or play an audio file, you can use the Silverlight MediaElement control. You can include the video or audio file in your project and set the Build Action property to Content and the Copy to Output Directory property to Copy if newer or Copy Always, and then specify it as the source of the control.

<MediaElement Source=”MyVideo.wmv” Width=”300″ Height=”300″

Alternatively, you can specify a remote URL for the video or audio file, and it will be streamed or downloaded and played just as in a Web browser. For a list of the supported video and audio formats, see “Supported Media Codecs for Windows Phone” on MSDN ( For information about using the MediaElement control, see “MediaElement” on MSDN (

An alternative approach for video and audio files is to use the MediaPlayerLauncher task. You create an instance of this class, set the required properties, and the call the Show method. In this example, the Build Action property of the video file is set to Content and the Copy to Output Directory property is set to Copy if newer so that the video file is included in the XAP file uploaded to the device.

MediaPlayerLauncher mediaLauncher = new MediaPlayerLauncher();
mediaLauncher.Controls = MediaPlaybackControls.All;
mediaLauncher.Location = MediaLocationType.Install;
mediaLauncher.Media = new Uri(“MyVideo.wmv”, UriKind.Relative);

Alternatively, you can copy the media item to isolated storage on the device and specify the MediaLocation property as Media LocationType.Data. For more information, see “MediaPlayerLauncher Class” on MSDN (

Note: When using the MediaPlayerLauncher task in the emulator, you may find that video frames render only if you repeatedly click on the UI. Each click advances the video by one frame and then the display turns black.

Selecting a Photo on the Device

You can select an existing photo from the user’s media collection using the PhotoChooserTask class. You specify a callback handler to execute when the user selects a photo, and optionally the size for the picture that will be returned.

PhotoChooserTask photoTask = new PhotoChooserTask();
photoTask.Completed += new EventHandler<PhotoResult>
photoTask.PixelHeight = 500;
photoTask.PixelWidth = 500;

When the user selects a picture, the callback can obtain the name of the picture and the Stream instance pointing to it. You must decode the byte stream into an appropriate image format for display, such as in an Image control on the page, as shown here. To use this code, you must add a reference to the namespaces System.Windows. Media.Imaging and Microsoft.Phone (for the PictureDecoder class).

void PhotoTask_Completed(object sender, PhotoResult result)
if (result.Error == null && result.TaskResult == TaskResult.OK)
string fileName = result.OriginalFileName;
WriteableBitmap thePhoto = PictureDecoder.DecodeJpeg(
MyImageControl.Source = thePhoto;

For more information about using media such as photos, video, and audio on Windows Phone 7, see “Media for Windows Phone” ( and “Photos for Windows Phone” ( on MSDN.


Previous articleThe Bing Maps Silverlight Control
Next articleSearch


Please enter your comment!
Please enter your name here

Latest News

Underlight As Accent, For Power and The Main Light for Photography

Underlighting, in which fill or accent light comes from under the topic, is not widely used technique in the traditional Portraits,...

How To Fix Overexposure As A Creative Tool, The Complete Guide

As an creative tool, overexposure is sort of underrated. What I’m close to propose could be a deliberate and well thought out technique for...

7D Mark II is Canon’s best DSLR cameras without full-frame sensor.

The expected long-awaited Canon EOS 7D Mark II are shipping in November for $ 1,799 without a lens. With a higher price tag, you...

Low key photography and How to isolate your subject.

Low key photography doesn’t depend on underexposure to make its point; the key to low key is that the majority of tones, even correctly...

High Key Lighting Techniques for Professional Photographers

I’ve written many times about high key lighting techniques and how to achieve them. The term “high key” is a bit misleading. As I’ve...

More Articles Like This

blograby facebook like page