NAME
Win32::MediaPlayer - Module for playing sound MP3 / WMA / WAV / MIDI file on Win32 platforms
SYNOPSIS
use Win32::MediaPlayer;
$winmm = new Win32::MediaPlayer; # new an object
$winmm->load('d:/10.mp3'); # Load music file disk, or an URL
$winmm->play; # Play the music
$winmm->volume(100); # Set volume after playing
$winmm->seek('00:32'); # seek to
#$winmm->pause; # Pause music playing
#$winmm->resume; # Resume music playing
print 'Total Length : '.$winmm->length(1),$/; # Show total time.
while(1) {
sleep 1;
print 'Now Position: '.$winmm->pos(1)."\r"; # Show now time.
};
DESCRIPTION
This module allows playing of sound format like MP3 / WMA / WAV / MIDI on Win32 platforms using the MCI interface (which depends on winmm.dll).
REQUIREMENTS
Only working on Win32, and you should installed the Win32::API
if not you can install by ppm, in the console mode
type command:
ppm install http://www.bribes.org/perl/ppm/Win32-API.ppd
USAGE
new
The new method is the constructor. It will build a connection to the mci interface.
$winmm = new Win32::MediaPlayer; # new an object
load()
$winmm->load('d:/10.mp3'); # Load music from the disk, or Internet URL.
play
$winmm->play; # Play the music file.
seek()
The value should be a format like XX:XX, or you can fill the micro second integer of the music.
$winmm->seek(100000); # Seek the music file, at the 100 sec pos.
$winmm->seek('01:40'); # Seek the music file, at the 01 min 40 sec pos.
close
$winmm->close; # Close the music file.
volume()
The value is from 0 to 100
$winmm->volume(100); # Set volume to 100 after playing
length()
Return the music total length
$length = $winmm->length(1); # Return the length in XX:XX format.
$length = $winmm->length; # Return the length in micro second integer.
pos()
Return the music now position
$length = $winmm->pos(1); # Return the Position in XX:XX format.
$length = $winmm->pos; # Return the Position in micro second integer.
pause
Pause the music play
$length = $winmm->pause; # Pause the music play.
resume
Resume the music play
$length = $winmm->resume; # Resume the music play.
AUTHOR
Lilo Huang
COPYRIGHT
Copyright 2006 by Lilo Huang All Rights Reserved.
You can use this module under the same terms as Perl itself.