Hi,
I am trying to play a local MP3 / wav file in WPF form but unable to here sound. System is not giving any error but sound cannot be heard. I am able to play file form windows media player outside the application.
Here is the xaml code
<MediaElement Canvas.Left="441" Canvas.Top="395" Height="18" Name="mysound" Width="24" MediaOpened="mysound_MediaOpened" Volume="1" LoadedBehavior="Manual" />
and cs code:
private void button1_Click(object sender, RoutedEventArgs e)
{
mysound.Source = new Uri("/sounds/jungle_drum.wav", UriKind.Relative);
mysound.Play();
}
I tried both UriKind.Relative and Absolute but it didn't work. Sounds folder is in the root of project folder.
Can anyone help me debugging?
Regards.
Dilip
Loading
Dilip AptePosted Jul 16, 2010, 1:07 AM
Thanks for your attachments. Actually your application also did not work on my machine. I figured out the issue. It was the windows media player version. I installed version 10 and it resolved the issue.
Thanks
Nishant RanaPosted Jul 12, 2010, 7:00 AM
I've attached a sample application which works..
Info: build in blend 4/VS2010
Hope it helps for ur solution
Cheers
Nishant Rana
Dilip AptePosted Jul 12, 2010, 6:14 AM
No luck..still do not work. Attaching original code...pls chk
Nishant RanaPosted Jul 12, 2010, 5:28 AM
if it dosent work.. then try to send me the piece of code....
though i think it should work fine
Cheers
Nishant Rana
Dilip AptePosted Jul 12, 2010, 5:15 AM
I tried this but no sound....what could be the reason? I checked my speakers!! Its working outside application !!
Nishant RanaPosted Jul 12, 2010, 5:03 AM
for me I used using following:
mysound.Source = new Uri("C:\\Media\\test.mp3");
It worked fine for me and i was able to hear sounds.
Cheers
Nishant Rana