in reply to Win32::MediaPlayer not playing sound

I would try using the older wheel Win32::MCI::Basic / Win32::MCI::CD , it comes with mciGetErrorString

site:perlmonks.org Win32::MCI -> Get CDDB info on Win32

update: And it works on WinXP :)

#!/usr/bin/perl -- use strict; use warnings; use Win32::MCI::Basic; Main( @ARGV ); exit( 0 ); sub Main { my $sFileName = shift or die "Usage: $0 C:\media\sh-boom.mp3 \n"; Shabba( qq{open "$sFileName" alias MediaFile } ); # OK! ## http://msdn.microsoft.com/en-us/library/ms709461%28v=VS.85%29.aspx# + MCI my $length = Shabba( qq{status MediaFile length } ); Shabba( qq{play MediaFile from 0 } ); my $position = Shabba( qq{status MediaFile position} ); while ( $position < $length ){ sleep 1; $position = Shabba( qq{status MediaFile position} ); } Shabba( qq{close MediaFile } ); } sub Shabba { my $lpszCommand = shift; my ( $APICallReturnValue, $lpszReturnString ) = mciSendString($lps +zCommand); my $lpszErrorText = mciGetErrorString( $APICallReturnValue ); no warnings 'uninitialized'; print " \$lpszCommand : $lpszCommand \$APICallReturnValue : $APICallReturnValue \$lpszReturnString : $lpszReturnString \$lpszErrorText : $lpszErrorText ---- "; return $lpszReturnString ; } __END__

update: Win32::MediaPlayer has $mciSendString = new Win32::API( "winmm", "mciSendString", ['P', 'P', 'N', 'N'], 'N' )

Where as Win32::MCI::Basic has  new Win32::API('winmm',    'mciSendString',    ['P','P','I','P'],    'N');

Sometimes old wheels are better :)

Replies are listed 'Best First'.
Re^2: Win32::MediaPlayer not playing sound
by Anonymous Monk on Jan 02, 2012 at 04:15 UTC