Sign in to follow this  
Followers 0
Frogger

SoundPlay Problems

11 posts in this topic

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 ;)

Share this post


Link to post
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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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.

Share this post


Link to post
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.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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.

Share this post


Link to post
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.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

how bout reverse the order?

soundplay

msgbox


[right][font="Courier New"]...Run these streets all day, I can sleep when I die.[/font] [/right]

Share this post


Link to post
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)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
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.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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
Sign in to follow this  
Followers 0