C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Play Audio File (Wav)


Posted Date: 22 Sep 2007    Resource Type: Code Snippets    Category: Sounds

Posted By: VASANTH R       Member Level: Gold
Rating:     Points: 10



.NET 2.0 provides System.Media Name space to play audio file.

The following code sample shows how to play an audio file using VB.NET


// To play a File from a disk locaiton
Dim objPlayer As New SoundPlayer
objPlayer.SoundLocation = "C:\Alert.wav"
objPlayer.Play()

// To play a File from applcation as embedded resouce
Dim objPlayer As New SoundPlayer
objPlayer.Stream = GetEmbeddedResourceStream()
objPlayer.Play()

Protected Function GetEmbeddedResourceStream() As Stream
Dim objAssembly As System.Reflection.Assembly
Dim soundstream As Stream
objAssembly = System.Reflection.Assembly.LoadFrom(Application.ExecutablePath)
soundstream = objAssembly.GetManifestResourceStream("Alert.wav")
return soundstream
End Function




Responses

Author: Satyanarayan SushilKumar Bajoria    30 Jun 2008Member Level: Diamond   Points : 2
Hi,

Nice piece of code on sound player.

I want to play mp3 format will this player plays that if not give me some suggestion how to create mp3 player.

Thanks for sharing your knowledge.

Keep posting.

Thanks and Regards
S.S.Bajoria


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Text To Speech Conversion - convert text to voice
Previous Resource: Playing Sound using Win API
Return to Discussion Resource Index
Post New Resource
Category: Sounds


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use