Sign in to follow this  
Followers 0
ravenfyre

No Longer Hear Mp3 Sounds Played Through Autoit

12 posts in this topic

I have an interesting problem. It has been a while since I used one of my scripts which uses soundplay to give a sound confirmation that an action took place.

I tried the script now and the sounds didn't play. All the files are in mp3 format, so I tried wav next and to my suprise wav played fine. Tried mp3 again, nothing. Filepaths are correct by the way, it just won't play mp3 files anymore.

Between the time I used this script last, when it worked perfectly, and now, I installed the new MS Media Player 10 beta. It's possible that has something to do with it, but I thought AutoIt played the sound files itself instead of relying on another program.

Any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I too have the ver 10.00.00.3473 beta... Just tried to soundplay an mp3 and it doesn't work for me either...

Edit: Once I changed the soundplay to keep wait until the sound was finished to continue the script (one line script) it works.

SoundPlay("C:\Program Files\Winamp\demo.mp3",1)
Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Oh, duh. I forgot to point that out. When I saw the bug-fix for another Soundplay issue, I forgot to point out that when not waiting for the sound to finish playing, the handle to the file will be closed immediately and no sound will play.

Although I didn't write the code or introduce the bug, I did see it and forgot to mention it, sorry about that.

Share this post


Link to post
Share on other sites

Well the bug was that if you played a sound and waited for it to finish and then tried to delete the file you couldn't because it was locked. The only change was to add to "close" after the "wait". And this seems to have broken mp3 playing?

It was this:

void Util_SoundPlay(const char *szFilename, bool bWait)
{
    AString sMCI;
    char    szBuffer[256];

    sMCI = "open ";
    sMCI += '"';
    sMCI += szFilename;
    sMCI += '"';
    sMCI += " alias PlayMe";

    mciSendString("status PlayMe mode",szBuffer,sizeof(szBuffer),NULL);

    if ( !szBuffer[0] == '\0' )
  mciSendString("close PlayMe",NULL,0,NULL);

    if ( mciSendString(sMCI.c_str(),NULL,0,NULL)==0 )
    {
  if (bWait)
            mciSendString("play PlayMe wait",NULL,0,NULL);
  else
            mciSendString("play PlayMe",NULL,0,NULL);
    }

} // Util_SoundPlay()

and the non-mp3-playing-current version is this:

void Util_SoundPlay(const char *szFilename, bool bWait)
{
    AString sMCI;
    char    szBuffer[256];

    sMCI = "open ";
    sMCI += '"';
    sMCI += szFilename;
    sMCI += '"';
    sMCI += " alias PlayMe";

    mciSendString("status PlayMe mode",szBuffer,sizeof(szBuffer),NULL);

    if ( !szBuffer[0] == '\0' )
  mciSendString("close PlayMe",NULL,0,NULL);

    if ( mciSendString(sMCI.c_str(),NULL,0,NULL)==0 )
    {
  if (bWait)
  {
            mciSendString("play PlayMe wait",NULL,0,NULL);
    mciSendString("close PlayMe",NULL,0,NULL);
  }
  else
            mciSendString("play PlayMe",NULL,0,NULL);
    }

} // Util_SoundPlay()

So just a single line added in (bWait).

:ph34r:

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I've got the .102 RC installed now... and this works:

;test soundplay

SoundPlay("C:\Program Files\Winamp\demo.mp3",0)

while 1
   sleep(50)
Wend

Oddly enough, this worked too:

SoundPlay("C:\Program Files\Winamp\demo1.mp3", 0)

$test = FileMove("C:\Program Files\Winamp\demo1.mp3","C:\Program Files\Winamp\demo.mp3")
MsgBox(4096,'debug:' , '$test:' & $test);### Debug MSGBOX

yeah, I was able to rename as the file played.

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

FileMove is a copy/delete . Did the delete part work?

LAr.

<{POST_SNAPBACK}>

Yes, and it returned a 1 for success on the filemove.

Also, as soon as I click OK for the debug it closes the script and stops playing the sound. This is by design, I'm sure, and I'm sure not complaining, just mentioning it. The file is definately moved while still playing.

And, just to triple check, it works like this, filedelete while playing:

(I'm preserving it with the filecopy, I just enjoy whipping that Lama's ass, don't want to loose that :ph34r: )

$play = "C:\Program Files\Winamp\demo.mp3"

SoundPlay($play, 0)

$test = FileCopy($play , "C:\Program Files\Winamp\demo1.mp3")
MsgBox(4096,'debug:' , '$test:' & $test);### Debug MSGBOX 
$delete = FileDelete($play)
MsgBox(4096,'debug:' , '$delete:' & $delete);### Debug MSGBOX
Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

lol didn't expect so many view/replies for just a soundplay problem, guess it's as buggy as you guys make it out to be ^^

I tried setting the wait command to 1 but unfortunately that didn't help at all. Meh I'll just convert everything back to wav =)

Share this post


Link to post
Share on other sites

I am so sick of SoundPlay.  I swear that it has never worked and every time we try and fix it it just gets worse.  I'm just going to cut the thing and be done with it.  :ph34r:

<{POST_SNAPBACK}>

Ummm it's part of my workout timer

Please please please please keep it

Rick


Only $2.00 with Resale Rights How to Block Better for Martial Artists and NonMartial Artistshttp://kirkhamsebooks.com/MartialArts/Bloc...tterEbook_m.htm

Share this post


Link to post
Share on other sites

Just a side note, I love that little rant emoticon. I could watch it all day.


Who else would I be?

Share this post


Link to post
Share on other sites

lol didn't expect so many view/replies for just a  soundplay problem, guess it's as buggy as you guys make it out to be ^^

I tried setting the wait command to 1 but unfortunately that didn't help at all.  Meh I'll just convert everything back to wav =)

<{POST_SNAPBACK}>

could it have something to do with the format of the mp3's? do they play in media player? I'm not having any issues with mine... very odd. I was thinking about how much time I'd thought about this... don't know why I did at all, I've never used soundplay in a script yet.

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

I think the old way is best. if someone needs to delete a SoundPlayed file they can call SoundPlay with "" or a nonsense file "nonsense.wav". That will free up the file they want to delete. Or add a SoundPlayRelease() command

Lar.

<{POST_SNAPBACK}>

I'm the guy who moaned about not being able to delete a wav file after having just SoundPlay'd it. :( Had I known that

SoundPlay("")

would have been an easy work-around to free up the file, I'd have been all over it! It isn't entirely intuitive though - perhaps just add that bit of information to the help file and leave things like they were...

Sorry for the trouble! :ph34r:

Nap

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