NAME

Audio::Play::MPG123 - a frontend to mpg123 version 0.59r and beyond.

SYNOPSIS

use Audio::Play::MPG123;

$player = new Audio::Play::MPG123;
$player->load("kult.mp3");
print $player->artist,"\n";
$player->poll(1) until $player->stat == 0;

$player->load("http://x.y.z/kult.mp3");

# see also mpg123sh from the tarball

DESCRIPTION

This is a frontend to the mpg123 player. It works by starting an external mpg123 process with the -R option and feeding commands to it.

METHODS

new

This creates a new player object and also starts the mpg123 process.

load(<path or url>)

Immediately loads the specified file (or url, http:// and file:// forms supported) and starts playing it.

pause

Pauses or unpauses the song. state can be used to find out about the current mode.

jump

Jumps to the specified frame of the song. If the number is prefixed with "+" or "-", the jump is relative, otherweise it is absolute.

stop

Stops the currently playing song and unloads it.

opts(<flags>)

Sets various flags. At the moment, only "1" or "0" is supported, which enables or disabled automatic position reports.

state

Returns the current state of the player:

0  stopped, not playing anything
1  paused, song loaded but not playing
2  playing, song loaded and playing
poll(<wait>)

Parses all outstanding events and status information. If wait is zero it will only parse as many messages as are currently in the queue, if it is one it will wait until at least one event occured.

This can be used to wait for the end of a song, for example. This function should be called regularly, since mpg123 will stop playing when it can't write out events because the perl program is no longer listening...

title artist album year comment genre url type layer samplerate mode mode_extension framesize channels copyrighted error_protected title artist album year comment genre emphasis bitrate extension

These accessor functions return information about the loaded song. Information about the artist, album, year, comment or genre might not be available and will be returned as undef.

IN

returns the input filehandle from the mpg123 player. This can be used for selects() or poll().

AUTHOR

Marc Lehmann <pcg@goof.com>.

SEE ALSO

perl(1).