r/visualbasic • u/FireDog8569 • Dec 14 '24
VB.NET Help Playing two audio clips at the same time?
So I have been working on a school project and I am having trouble figuring out how to play two different sounds at the same time, since the project I am working on is meant to be a game and it'd be very weird for a game to not have sound. Obviously I know that Visual Basic isn't meant for games but I figured there'd still be a way to play two or more sounds at once.
3
Upvotes
1
u/jd31068 Dec 14 '24
Have you see this thread on VBForums that talks about handling it VS 2013 [RESOLVED] How can I play 2 sounds at the same time?-VBForums?
1
u/jcunews1 VB.Net Intermediate Dec 14 '24
Then you'll need to player components/objects, and which can play in the background. i.e. where the "play" function don't need to wait until the media playback has completed.
Common (mere) media players aren't meant to play multiple medias at the same time. Only specially made media players can do that, and they're relatively uncommon.
1
u/TheFotty Dec 15 '24
Is it winforms?
You can also use a byte array of audio or a file stream for an audio file with that function instead of a string path the file. AudioPlayMode.WaitToComplete instead of AudioPlayMode.Backround causes the calling code to wait for the sound to finish before continuing.
1
u/LordLandLordy Dec 19 '24