NAME
POE::Component::MPG123
SYNOPSIS
use POE qw(Component::MPG123);
my $alias = 'mp3weazel';
POE::Component::MPG123->spawn( alias => $alias );
$poe_kernel->run();
DESCRIPTION
POE Component for accessing and working with mpg123, an mp3 player.
PoCo::MPG123's spawn()
method takes one named parameter:
- alias
-
alias => $alias
alias
is the name of a session to which the callbacks below will be posted. This defaults to console.
Available events
All events are posted to a session named mpg123
.
- play
-
$kernel->post( mpg123 => play => $filename );
Load and play the mp3 found at
$filename
. The parameter must either be an existing mp3 file or the full url to an mp3 stream. - stop
-
$kernel->post( mpg123 => 'stop' );
Stop playing the current track and unload it. This is like pressing stop on your CD player, not your cassette tape deck. The track is actually unloaded and you cannot continue from where you left off.
- pause
-
$kernel->post( mpg123 => 'pause' );
Pause or unpause the current track.
- vol
-
$kernel->post( mpg123, vol => $vol );
Sets the volume. The $vol parameter should be an integer between 0 and 100 (inclusive) representing the percentage to set. Note that this command can only be used with a patched version of mpg123 that supports the VOL command. Use of this command in unpatched versions will result in undetermined behaviour.
- xcmd
-
$kernel->post( mpg123, xcmd => $cmd );
This message allows posting to the player any command not currently built into this component. Use at your own risk!
- quit
-
$kernel->post( mpg123 => 'quit' );
Stop playing the current track and shut down the mpg123 process.
Callbacks
As noted above, all callbacks are either posted to the session alias given to spawn()
or console
.
- status
-
Fired during playback. ARG0 is the number of frames played up till now. ARG1 is the number of frames remaining to be played. ARG2 is the number of seconds played. ARG3 is the number of seconds remaining in the track.
- song_info
-
Fired when a song is loaded. ARG0 is a hash ref containing either ID3 tag information or the filename (if there is no ID3 tag). The
type
element of the hash is set to id3 in the former case and filename in the latter case. For type id3, the hash elements are title, artist, album, year, comment, and genre. For type filename, the hash elements are filename. - file_info
-
Fired when a song is loaded. ARGO is a hash ref containing information about the mp3 file/stream itself. Hash elements are type, layer, samplerate, mode, mode_extension, bpf, channels, copyright, crc, emphasis, bitrate, extension, and lsf.
- song_stopped
-
Fired when a song stops. No args.
- song_paused
-
Fired when a song becomes paused. No args.
- song_resumed
-
Fired when a song resumes playback. No args.
- song_ended
-
Fired when playing a song has finished.
- player_quit
-
Fired when mpg123 goes away, either as the result of something stupid happening in mpg123 itself or as a result of a
quit
event. Suggested use is to either quit gracefully or create a new player. - debug
-
Fired when there is random not-useful-to-normal-people information. ARG0 is a string containing the debug message. Not recommended for production use.
AUTHOR
Matt Cashner (eek+poe@eekeek.org)
Erick Calder (ekkis@cpan.org)
Rocco Caputo (troc@netrus.net)
DATE
$Date: 2002/06/26 00:50:23 $
VERSION
$Revision: 1.14 $
LICENSE AND COPYRIGHT
Copyright (c) 2000-2002 Matt Cashner, Erick Calder, and Rocco Caputo. This product is distributed under the MIT License. A copy of this license was included in a file called LICENSE. If for some reason, this file was not included, please see http://www.opensource.org/licenses/mit-license.html to obtain a copy of this license.
4 POD Errors
The following errors were encountered while parsing the POD:
- Around line 305:
'=item' outside of any '=over'
- Around line 344:
You forgot a '=back' before '=head2'
- Around line 349:
'=item' outside of any '=over'
- Around line 400:
You forgot a '=back' before '=head1'