Too busy playing music to do anything else...

machinogodzilla

Active member
Joined
Mar 3, 2007
Messages
25
Programming Experience
Beginner
Hi!


I use a function

VB.NET:
Function PlayWav(ByVal fileFullPath As String) As Boolean

        My.Computer.Audio.Play(fileFullPath, AudioPlayMode.WaitToComplete)

End Function
to play a sound in my program. The problem is that anything else cannot
be done by the program until the sound has finished. Even the timer waits
patiently and stops ticking.


Any solution?


Regards,
machinogodzilla
 
Import realplayer dll? Then set it so it's hidden.

edit:

I have never used
AudioPlayMode maybe try AudioPlayMode.Background?
 
My.Computer.Audio.Play(fileFullPath, AudioPlayMode.WaitToComplete)
You have specifically told it to do so with AudioPlayMode.WaitToComplete, use one of the other options.

Your function is also not a Function method, it doesn't return a value, it's a Sub method.
 
===>> [resolved] <<===

You have specifically told it to do so with AudioPlayMode.WaitToComplete
Doh!


Your function is also not a Function method, it doesn't return a value, it's a Sub method.
This is obviously correct and I am going to stick it to my head.

But is it just a good manner to call things properly or does it make the
difference for the compiler when you write the code? I am asking
because vb.net takes both

VB.NET:
Public Function PlayWav(ByVal fileFullPath As String) As Boolean
and

Public Sub PlayWav(ByVal fileFullPath As String)
and execute the program as expected.

I am sorry if the question is tryvial but it's all new to me.



Thank you very much for your help!
 
machinogodzilla said:
I take it you found the background options working...
machinogodzilla said:
This is obviously correct and I am going to stick it to my head.
Besides the memory allocation difference - memory have to be allocated for the return value of a function call - it is plain wrong to write a method as a function when you don't intend to return anything from it. Even if there is a default value for Boolean returned it doesn't make sense.
 
Back
Top