Sign in to follow this  
Followers 0

SoundPlayClose() to close the sound handle

13 posts in this topic

Posted

Hi,

I reported about SoundPlay() function problem here, and i thought that this is a bug, i understand now (after Valik has explained to me - thanks :P ) that it isn't - but now it would be great to have function like SoundPlayClose() (a proposal from Valik), and the function SoundPlay() should return a handle to the sound file if we use 0 as second parameter (no wait), so later in the script we could close this handle using new func SoundPlayClose(), this will help as to delete the sound file (if needed, if it is a FileInstall'ed temporary file) before we exit the script.

Thanks.

Share this post


Link to post
Share on other sites



Posted

Sound.au3 has _SoundOpen and _SoundClose, look at the helpfile. AutoIt's built in soundplay basically does the same stuff as sound.au3, except does not close the mci alias used. In your case you would use:

#include <sound.au3>
$hSound = _SoundOpen("file.mp3")
_SoundPlay($hSound)
;rest of script
_SoundClose($hSound)

@dev's

Could you possibly tell me the alias AutoIt uses when using SoundPlay? That way I could put it in _SoundClose remarks rather than a new built in function. (Up to you of course).

Share this post


Link to post
Share on other sites

Posted

Sound.au3 has _SoundOpen and _SoundClose, look at the helpfile. AutoIt's built in soundplay basically does the same stuff as sound.au3, except does not close the mci alias used. In your case you would use:

#include <sound.au3>
$hSound = _SoundOpen("file.mp3")
_SoundPlay($hSound)
;rest of script
_SoundClose($hSound)

@dev's

Could you possibly tell me the alias AutoIt uses when using SoundPlay? That way I could put it in _SoundClose remarks rather than a new built in function. (Up to you of course).

"PlayMe" :)

Share this post


Link to post
Share on other sites

Posted

Sound.au3 has _SoundOpen and _SoundClose, look at the helpfile

I know, thanks, but i thought that the built-in functions (Sound..()) should be able to release the sound handle, so we could use simple SoundPlay() (without including whole library of _Sound...()) and delete the file later.. i think if it Open the handle, it should have some tool to close it.

Share this post


Link to post
Share on other sites

Posted

*Bump* :)

Share this post


Link to post
Share on other sites

Posted

What about doing it this way ?

FileCopy(@WindowsDir & "\media\tada.wav", @ScriptDir & "\tada.wav")
SoundPlay(@ScriptDir & "\tada.wav", 0)
Sleep(5000)
SoundPlay("")
FileDelete(@ScriptDir & "\tada.wav")

Share this post


Link to post
Share on other sites

Posted

That's a good idea. We should just document that as the functionality to close a SoundPlay() handle.

Share this post


Link to post
Share on other sites

Posted

That's a good idea. We should just document that as the functionality to close a SoundPlay() handle.

It is also the way to stop the soundfile from playing when submitted in the background so maybe add that too when updating the Helpfile page remarks section?

Share this post


Link to post
Share on other sites

Posted

A full sound function would be nice,

-Play

-Stop

-Pause/resume

-Length (or time when it will stop by itself)

If there was something like this we could open up way more possibilities.

Work with wavs and mp3's (which I think it does now for soundplay)

Share this post


Link to post
Share on other sites

Posted (edited)

A full sound function would be nice,

-Play

-Stop

-Pause/resume

-Length (or time when it will stop by itself)

If there was something like this we could open up way more possibilities.

Work with wavs and mp3's (which I think it does now for soundplay)

We already have those. :)

These play Wav, MP3, and I think WMA.

_SoundPlay()

_SoundStop()

_SoundPause()

_SoundResume()

_SoundPos() (I Think)

Edited by JustinReno

Share this post


Link to post
Share on other sites

Posted (edited)

These play Wav, MP3, and I think WMA

Also MIDI

there are:

_SoundOpen

_SoundClose

_SoundPlay

_SoundPause

_SoundSeek

_SoundStop

_SoundLength

_SoundResume

_SoundStatus

_SoundPause

EDIT: along with MIDI there is ogg

Edited by DBak

Share this post


Link to post
Share on other sites

Posted

EDIT: along with MIDI there is ogg

How did you get it to play ogg??

Share this post


Link to post
Share on other sites

Posted

I've added some remarks in the documentation about SoundPlay(""). Moving this to Complete.

Share this post


Link to post
Share on other sites
Sign in to follow this  
Followers 0