in reply to Playing wav files
Win32::Sound has direct access to the various Windows sounds: to test that everything's working okay,
... when I did that, all but SystemHand were the same -- probably because I don't have a lot of those sounds defined on my machine (I like a quiet machine).perl -MWin32::Sound -le "print($_), Win32::Sound::Play($_) for qw/Syst +emDefault SystemAsterisk SystemExclamation SystemExit SystemHand Syst +emQuestion SystemStart/"
If you go to cpanm --look Win32::Sound, which (if you have cpanminus (*)) will put you into the distro-directory for Win32::Sound, then cd into the samples directory, you should be able to run sinus.pl and hear a tone (the note A). Then perl -MWin32::Sound -le "Win32::Sound::Play('welcome.wav')" should play a small sound. (*: if you don't have cpanminus, download the Win32::Sound tarball and untar it, then go into the samples subdirectory.)
My guess is what's happening in your example is that it's not finding $wav_file. In the same directory as welcome.wav above, run
. This should play the welcome sound twice, then play the system default (because it didn't find DNE.wav), then play nothing (because it didn't find DNE.wav and was set to no default)perl -MWin32::Sound -le "for(qw/welcome.wav DNE.wav/) { print qq(With +Default: $_); Win32::Sound::Play($_); sleep(1); print qq(No Default: +$_); Win32::Sound::Play($_,SND_NODEFAULT); sleep(1); }"
|
|---|