in reply to Win32::Sound module problem

please help

You forgot to use Win32::Sound; :D

It seems, you need the process (thread) to live, for the sound to get played

This (sleep) works, it makes noise

perl -MWin32::Sound -e " Win32::Sound::Play( qq[$ENV{WINDIR}/media/cho +rd.wav] , SND_ASYNC ); sleep 3; Win32::Sound::Stop(); "
Omit the sleep and it doesn't make noise. Looping also works
perl -MWin32::Sound -e " Win32::Sound::Play( qq[$ENV{WINDIR}/media/cho +rd.wav] , Win32::Sound::SND_ASYNC() | Win32::Sound::SND_LOOP() ); sle +ep 3; Win32::Sound::Stop(); "

Don't mess with volume, that is users job :)

Replies are listed 'Best First'.
Re^2: Win32::Sound module problem
by palkia (Monk) on Jul 19, 2011 at 00:08 UTC
    Don't worry, I did "use" in my code ^^.

    Thank you very much you're totally right.
    I thought the "play" function makes windows itself play the sound (independently to the program),
    which is of low probability when considering the default waits the sound to end before continuing the program.
    My "play" call really was the last code line (was a test), so my sound probably played for just a microsec XD (nice catch).
    Thx again :-]

    Btw: I'm with you on the volume thing (which from some reason doesn't do the percentages right), but I do like that I have the option ^^.