Click here to Skip to main content
15,906,097 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi,

I have a window based vb.net application.

In my application I have added a media player.
Whenever I play a sound my application freezes while the sound plays.

Suppose I have a sound file for duration 3 sec then my application also freeze for 3 sec.

I also need to know how do I play .wav file from resources?

thanks in advance
Posted
Updated 20-Apr-11 21:49pm
v2
Comments
Dalek Dave 21-Apr-11 3:50am    
Edited for Grammar, Syntax and Readability.

Open a new thread and play the sound in that thread.
That way, the thread which handles your GUI won't be blocked.
 
Share this answer
 
Comments
kals84 21-Apr-11 3:37am    
can i use backgroundworker to play sound
Wannes Geysen 21-Apr-11 3:44am    
I don't see any problem in using a backgroundworker to play the sound
Sergey Alexandrovich Kryukov 21-Apr-11 4:30am    
Will work, I'll guarantee that.
--SA
Dalek Dave 21-Apr-11 3:50am    
Yep, threads!
kals84 21-Apr-11 4:05am    
Media file in backgroundworker is working now.. but i can t find solution to my second question
Hey Kals84 for your second question which is about playing .wav file from resources I found this [^] article might help you.
 
Share this answer
 
Comments
Tarun.K.S 21-Apr-11 4:11am    
It should work now. 5+
Sergey Alexandrovich Kryukov 21-Apr-11 4:37am    
Ravi,
I vote 5, but when I saw it... I think the solution should be more simple than in this reference. I do not have VB.NET installed (and don't want it) to do it all, but resource auto-generates C# (and must be VB.NET) code file with static property representing the resource. It can be used as a stream, and then all like in code sample...
--SA
Here[^] and here[^] may help.
 
Share this answer
 
Comments
Tarun.K.S 21-Apr-11 4:10am    
This should help the OP. 5+
Sergey Alexandrovich Kryukov 21-Apr-11 4:31am    
Basic stuff for Basic.NET... could... help. A 5. :-)
--SA
hi,

thanks all for your suggestions and time for reply.

but i found a very quick and small methos to play sound file

If My.Resources.welcome.CanRead Then
  Dim bStr(My.Resources.welcome2.Length) As Byte
  My.Resources.welcome.Read(bStr, 0, My.Resources.welcome.Length)
  My.Computer.Audio.Play(bStr, AudioPlayMode.Background)
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900