Thursday, May 19, 2011

How to Play Audio, Video, Files transfer, Isolated Storage Explorer with Windows Phone 7 (WP7) Emulator


As a part of work I was gathering some information regarding playing media contents in Windows Phone 7 (WP7) emulator. I thought it is simple as similar with WM series devices. Though the code snippet for playing is not more than 5-7 lines but faced little problem while transferring media file from my hard drive to Emulator & playing the same.

In WM series devices we are transferring a file (manually) from desktop to Emulator either by using Active Sync or by using WMDC (Windows Mobile Device Center).
However in WP7 it is totally different. Here we need to install the WP7 Isolated Storage Explorer. It is local storage for WP7 applications & all I/O operations need to use it. You can download it from  HERE . Once you downloaded then follow the instructions .
Thanks to Microsoft Corporation for providing wonderful contents

Now its time for using MediaPlayerLauncher to play your media file.
Code snippet for playing media is as below :

 MediaPlayerLauncher objMPlayerLauncher = new MediaPlayerLauncher();
 objMPlayerLauncher.Media = new Uri("gags.wmv", UriKind.Relative); 
 //replace "gags" with your file path.
 objMPlayerLauncher.Location = MediaLocationType.Data;
 objMPlayerLauncher.Controls = MediaPlaybackControls.Pause| MediaPlaybackControls.Stop;
 objMPlayerLauncher.Show();

Please checkout this screen shot :


Hope this will helps.

4 comments:

  1. good one. Thanks

    ReplyDelete
  2. Hi is it possible now , with the last release "windows phone mango" , to write a stream of music in a file and play it in the same time??

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Hiya,
    I am not sure about this. I guess you need look around adaptive streaming with updated WP7 or else you can raise query in MS forums.

    Article by Giuseppe Guerrasio may help you :
    http://blogs.msdn.com/b/giuseppeguerrasio/archive/2010/12/06/using-smooth-streaming-media-element-for-windows-phone-7.aspx


    Regards,
    Mohsin

    ReplyDelete