Sound code that stops previous sound and plays another one

I've been trying all weekend to figure it out, I'm using the DLL file "winmm.dll" Alias "PlaySoundA" the function is "PlaySound".

This is the code I want to execute:
PlaySound ImageFolderPath & "7.wav", 0, &H11

(ImageFolderPath is my variable)

There may be sound playing when this is executed so that has to stop. This new sound needs to then loop until another sound is played.

I'm thinking the &H11 is where it's going wrong.

Any help will be massively appreciated.

A second problem I've been having, which I'm wanted to get around is that I can't call this code and have 2 or more sounds playing at the same time. Again, any help with this would be most appreciated.

Thanks in advance.

Comments

  • Clarifying my problem, the first time the sound is called it delays in some way in which the sound IS trying to run but no sound comes out. Any other time it's run, the sound plays exactly how I want it to. However, when I restart the computer, the next time I call the code the same problem happens as it considers it's the first time it's been run. Running the code again after means it runs as I want it, but this is far from ideal.

    Any help with this?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion