Hi I am working on Windows 7 based application development in Silverlight. I have not been able to find a way to play a an audio file in windows 7 phone programmatically. I have been googling it since past few days but i could not get any solution of that. There is a class SoundPlayer in C# but i guess its not available in Windows 7 Phone. Can anyone please help?
Best Regards
Answer: 1
Use Xna to play the sound. You can cross reference Xna from a Silverlight app though, for playing a sound file, you need to the following:
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio // ... Stream stream = TitleContainer.OpenStream("sounds/bonk.wav"); SoundEffect effect = SoundEffect.FromStream(stream); FrameworkDispatcher.Update(); effect.Play();
All the best for your application development!
Answer by vamana for Play an audio file in Windows 7 PhoneAnswer: 2
You can place a MediaElement in your XAML view:
<MediaElement x:Name="sound" Source="sound.wma" AutoPlay="False" />
then in the code-behind:
sound.Play();
Supported formats are MP3 and WMA.
Answer by Olivier Payen for Play an audio file in Windows 7 PhoneAnswer: 3
You can also try the MediaPlayerLauncher. For more information and sample code take a look at the following article.
"#5 How to use MediaPlayerLauncher in a WP7 app"
Hope this will help you.
Answer by Kate Brown for Play an audio file in Windows 7 PhoneAnswer: 4
You'll want to use MediaElement. Here's a tutorial
http://create.msdn.com/en-US/education/quickstarts/Video_and_Audio
Answer by Zain for Play an audio file in Windows 7 PhoneAnswer: 5
How about simply use a built-in behavior?
<Button> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <eim:PlaySoundAction Source="/Alarm1.wma" Volume="1"/> </i:EventTrigger> </i:Interaction.Triggers> </Button>
You need these two namespaces.
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:eim="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions"
Answer by Xin for Play an audio file in Windows 7 Phone
No comments:
Post a Comment
Send us your comment related to the topic mentioned on the blog