use POE qw(Component::MPG123);
my $alias = 'mp3weazel';

POE::Component::MPG123->spawn( alias => $alias );



POE Component for accessing and working with mpg123, an mp3 player.

PoCo::MPG123's "spawn()" method takes one named parameter:

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".

$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.

$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.

$kernel->post( mpg123 => 'pause' );

Pause or unpause the current track.

$kernel->post( mpg123 => 'quit' );

Stop playing the current track and shut down the mpg123 process.


As noted above, all callbacks are either posted to the session alias given to "spawn()" or "console".

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.

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.

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.

Fired when a song stops. No args.

Fired when a song becomes paused. No args.

Fired when a song resumes playback. No args.

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.

Fired when there is random not-useful-to-normal-people information. ARG0 is a string containing the debug message. Not recommended for production use.


Matt Cashner (

Rocco Caputo (


$Date: 2001/08/07 01:50:10 $




Copyright (c) 2000-2001 Matt Cashner 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 to obtain a copy of this license.