Must Read

Get rid of your Student Debt Faster: Government Student Loan Consolidation

Moreover, due to the high costs of education, studying material, rent, everyday expenses, etc. student loans are usually paid...

When Should I Shop, on a Cyber Monday or on a Black Friday?

You adored that 52 inch wide-screen LCD TV for six months now. However, you have put off the purchase...

Data protection risks

If a security breach results in sensitive customer details being stolen your business may be prosecuted by national authorities,...

Interacting with the DLR

The Dynamic Language Runtime (DLR) is a new feature of the .NET platform. Its intended purpose is to support...

The Code-Behind

Listing 2.2 contains the code-behind, which must handle all the special features of this flashlight—strobe mode, SOS mode, and...

Quickie Definition of a Blog

Here’s the plain-language, quickie answer to the “Er, what is a blawg?” question: A Weblog or blog is an instant...

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

Digital Marketing for Beginners

Digital marketing for starter, Let to basic learning about connecting with your audience in the right place...

What are 7 things poor people do that the rich don’t?

1. poor people watch TV in which people read books how many hours you spend in front of the TV and when...

Top 18 best small business ideas for beginners starting

A small business can be frightening and requires plenty of careful planning there are many small business ideas which can be beneficial...

Summer that makes you happy

We saw were already here I've been thinking about some of the things. I used to do with my husband even though...

4 Point to helpful tips specifically for caregivers

What you need to take a vacation. I know it sounds impossible creative and try to make it work for you almost...

More Articles Like This