multiple sounds -- argument issue

barkode

Member
Joined
Dec 30, 2011
Messages
14
Programming Experience
Beginner
so to play ONE sound you do this:


Sub PlayBackgroundSoundResource()
My.Computer.Audio.Play(My.Resources.Waterfall, AudioPlayMode.WaitToComplete)
End Sub

as explained HERE. But what if I have 2 or more sounds, what are the arguments of ​PlayBackgroundSoundResource() to be able to call different sounds for different reasons?
 
Here you can see what type of arguments the Play method will take: Audio Class
Reasoning is not part of method calls, that is done with Decision Structures
 
Here you can see what type of arguments the Play method will take: Audio Class
Reasoning is not part of method calls, that is done with Decision Structures

Thanks.

Actually I kept trying in the dark and this version works (I’m not quite sure why):

Sub PlayBackgroundSoundResource(hello)
My.Computer.Audio.Play(My.Resources.hello, AudioPlayMode.WaitToComplete)
End Sub

Private Sub BtnAdd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd1.Click

Dim hello As Object = 0
…………………………………….
PlayBackgroundSoundResource(hello)
End Sub

Yes, in that order, with “Dim hello” following the Sub where it was first used. I just hope it’ll keep running like this
 
You should turn on Option Strict to get better help with data types from Visual Studio.

Although you already have seen how to pass arguments to a procedure, read through this also: Procedure Parameters and Arguments

Then the first thing you should have a look at is the type of your resource. For example hover the .hello property in your code and a tooltip will show you its type, or you can go into the Resources page in project and select the resource there and Properties window shows its Type. Now you see the type of that resource is UnmanagedMemoryStream or just MemoryStream, what parameter type do you think that correspond to with the Play method? Does Play method have a parameter of type Stream?
 
Back
Top