Jump to content

SoundPlay Problems


Recommended Posts

I noticed a bug when playing sounds using the SoundPlay function. I was trying to add sounds to a program I wrote, located at www.sharemation.com/pcstudyguide/pcsgsetup.zip (in case you want to take a look). I was able to add a splash image & loading sound, for an intro, but I also wanted to add sounds to the other events in the program such as, closing down the program, deleting summary files, loading test files, saving/canceling the settings window, etc.

It seems that if I have variables set, the SoundPlay feature does not work correctly. I can get the intro(splash) sound to play correctly every time, and the exit sound works if I just open the program then close it. However, if I open the program and take a test, after I'm done taking the test and I close the program, it does not play the closing sound, even though it works just fine when I simply open the program then close it. This bug is really peculiar and has me tripping to find the solution.

At the moment, I don't have internet at home. I'm on a public computer now and forgot to bring some of my source code to include in this post(d'oh). If this isn't enough info to help find the problem, the next time I have access to the internet, I'll post some snippets of code. I really don't think it's syntax though.

Thanks for the help,

Frogger ;)

Link to comment
Share on other sites

I noticed a bug when playing sounds using the SoundPlay function. I was trying to add sounds to a program I wrote, located at www.sharemation.com/pcstudyguide/pcsgsetup.zip (in case you want to take a look). I was able to add a splash image & loading sound, for an intro, but I also wanted to add sounds to the other events in the program such as, closing down the program, deleting summary files, loading test files, saving/canceling the settings window, etc.

It seems that if I have variables set, the SoundPlay feature does not work correctly. I can get the intro(splash) sound to play correctly every time, and the exit sound works if I just open the program then close it. However, if I open the program and take a test, after I'm done taking the test and I close the program, it does not play the closing sound, even though it works just fine when I simply open the program then close it. This bug is really peculiar and has me tripping to find the solution.

At the moment, I don't have internet at home. I'm on a public computer now and forgot to bring some of my source code to include in this post(d'oh). If this isn't enough info to help find the problem, the next time I have access to the internet, I'll post some snippets of code. I really don't think it's syntax though.

Thanks for the help,

Frogger ;)

sounds to me like there are some logic errors in your code, that's just based off the inconsistent nature of the issues, specifically that it works fine if you just open and close. i'd have to see your code before i could offer anything more specific.
Link to comment
Share on other sites

sounds to me like there are some logic errors in your code, that's just based off the inconsistent nature of the issues, specifically that it works fine if you just open and close. i'd have to see your code before i could offer anything more specific.

Thx cameronsdad, I sent you a PM. I'm not sure what you mean by 'logic errors'. By the way, if I put a test message box right before the SoundPlay's that don't normally work, like this:

MsgBox( 0, "", "This is a test." )
SoundPlay( "C:\testsound.wav", 1 )
Exit

It will display the message box but will not play the sound. Very odd.

Link to comment
Share on other sites

Thx cameronsdad, I sent you a PM. I'm not sure what you mean by 'logic errors'. By the way, if I put a test message box right before the SoundPlay's that don't normally work, like this:

MsgBox( 0, "", "This is a test." )
SoundPlay( "C:\testsound.wav", 1 )
Exit

It will display the message box but will not play the sound. Very odd.

are you calling SoundPlay() with a literal string like in the example, or are you calling it with a variable like:

SoundPlay($testsound,1)

if you're using variables, use your message box to display the value of the variable right before playing. You may find that the value has changed depending on how it was declared or set.

Link to comment
Share on other sites

are you calling SoundPlay() with a literal string like in the example, or are you calling it with a variable like:

SoundPlay($testsound,1)

if you're using variables, use your message box to display the value of the variable right before playing. You may find that the value has changed depending on how it was declared or set.

I'm using a literal string, although it is more like SoundPlay( "sounds\shutdown.wav", 1 ) rather than the full path. The splash sound is played using SoundPlay( "sounds\startup.wav" ) and it works, so I figured that would do but I'll try using the full path as well, to see if that helps.
Link to comment
Share on other sites

I'm using a literal string, although it is more like SoundPlay( "sounds\shutdown.wav", 1 ) rather than the full path. The splash sound is played using SoundPlay( "sounds\startup.wav" ) and it works, so I figured that would do but I'll try using the full path as well, to see if that helps.

yes i'd definitely use either the full path, or atleast a full relative path like

@ScriptDir & "\..\sounds\filename.wav" just incase other operations in your script are changing the working directory.

Link to comment
Share on other sites

Hey cameronsdad, I tried setting the full path, it worked. ;) PC Study Guide is finally v2.0.1 but now I'm going to have to buy a domain and hosting, argh. The file size is more than 5mb now for the installation so I can't get it up on any free servers, d'oh.

Thanks again though, I'm putting a special thanks to you in the readme & docs. I'll post the new link to get it once I find a place to put it. (the images/sounds made it much larger)

Link to comment
Share on other sites

AutoIt needs to be in memory while the sound is played. Compare the performance of the scriptlets below:

; Sound won't play
SoundPlay(@WindowsDir & "\Media\Windows XP Startup.wav")
Exit

; Sound will play briefly
SoundPlay(@WindowsDir & "\Media\Windows XP Startup.wav")
Sleep(1000)
Exit

; Sound will finish -- note extra argument
SoundPlay(@WindowsDir & "\Media\Windows XP Startup.wav", 1)
Exit
Edited by LxP
Link to comment
Share on other sites

Hey cameronsdad, I tried setting the full path, it worked. ;) PC Study Guide is finally v2.0.1 but now I'm going to have to buy a domain and hosting, argh. The file size is more than 5mb now for the installation so I can't get it up on any free servers, d'oh.

Thanks again though, I'm putting a special thanks to you in the readme & docs. I'll post the new link to get it once I find a place to put it. (the images/sounds made it much larger)

awesome man, glad i could help.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...