Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Win32::MediaPlayer what the...

by Perforin (Novice)
on Jul 30, 2007 at 23:33 UTC ( [id://629697]=perlquestion: print w/replies, xml ) Need Help??

Perforin has asked for the wisdom of the Perl Monks concerning the following question:

Hi perlmonks!
I wrote a little skript for listening music in my little black box.I copied the code of the Thread from cpan.

And now I have a problem.The skript is printing the length of the track an the position, thatīs fine, but then when the track should be finished, my skript doesnīt continue? o.O
Here comes the code:
print 'Total Length : '.$winmm- length(1),$/; while(1) { sleep 1; print 'Now Position: '.$winmm- pos(1)."\r"; } $winmm- close; print " \n\n\nTrack finished! \n\n\n";
It should close the song and print that the Track is finished. Can somebody find out whatīs wrong?


P.s: Sorry for my bad english ;)

Replies are listed 'Best First'.
Re: Win32::MediaPlayer what the...
by ikegami (Patriarch) on Jul 31, 2007 at 00:34 UTC

    A look at Win32::MediaPlayer's reveals it's a thin wrapper for mciSendString. mciSendString has limited capability for feedback. (It can be polled, but that's it.) It seems to work a lot like a remote control. A remote control doesn't know if a CD player is still playing the track the remote asked it to play or not. The CD player provides the feedback directly to the user.

    I suggest you copy the contents of Win32::MediaPlayer — It doesn't have a C component — and play around. The status command might be useful.

Re: Win32::MediaPlayer what the...
by menolly (Hermit) on Jul 31, 2007 at 17:37 UTC
    You've got a while(1) loop that will never end. Someting like while($winmm->pos(1) < $winmm->length(1)) will likely work better.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://629697]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found