Tuesday 20 September 2011

Play sound with Windows Phone 7 SIlverlight App -

Hi all,

There's a time that I've used the Emulator for my dev purpose. One of my apps played a mp3 file, the file has been hard-coded for keeping the thing simple.
Today, I deployed it on my windows phone 7 device, and guess what ?!!! any sound played..., but it perfectly works on the emulator.
First,I think that it is a frequency and rate of the file which is not supported by my phone.So, I've moved the file via Zune on the phone and it can play the song.
What's the matter. I'm sure that my code is correct, but it must be something wrong somewhere.


In the MainPage.xaml, I've used the MediaElement like this :

<MediaElement x:Name="media" AutoPlay="True"  ></MediaElement>

And I the main Page, I've added those two lines after the InitializeComponent method

media.Source = new Uri("Audio/song1.mp3", UriKind.Relative);
media.Play();

When debuging using the device, the screen main application appears but I dont hear any song...

I don't see what's wrong... it becomes boring I've said. So decided to shutdown my PC, unplug the USB cable.... and guess what ???!!!!!  the song is being played ....

Finally, I found the solution... BEFORE TESTING ANY APPS, DISCONNECT FIRST THE USB CABLE

No comments:

Post a Comment