in reply to Win32::MediaPlayer not playing sound

Looking at the source of the module, it sets: $self->{play} = 0; in new().

And it issues the warning you are seeing from ->length() in line 58:

warn 'No File Loaded' if($self->{play}==0);

and ->volume() in line 44:

warn 'No File Loaded' if($self->{play}==0);

But ->load(), successful or not, doesn't set that variable:

sub load { my $self = shift; my $file = shift; $result = doMM("open \"$file\" type mpegvideo alias ".$self->{alias}); return $result; }

Only ->play() does:

sub play { my $self = shift; my $pos = shift || $self->{pos}; $self->{play} = 1; $result = doMM("play ".$self->{alias}." from $pos"); return $result; }

And it sets it regardless of whether the attempt to play the file was successful or not.

This doesn't help you fix your program, but it -- along with the lack of indentation and other clues in the source code; the age of the bug reports on RT; -- may give you an indication of the quality of this module and your chances of solving the problem.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?