Marc Lehmann > Audio-Play-MPG123-0.63 > Audio::Play::MPG123



Annotate this POD

View/Report Bugs
Module Version: 0.63   Source  




  use Audio::Play::MPG123;
  $player = new Audio::Play::MPG123;
  print $player->artist,"\n";


  # see also mpg123sh from the tarball


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.

While the standard mpg123 player can be used to play back mp3's using this module you will encounter random deadlocks, due to bugs in its communication code. Also, many features (like statfreq) only work with the included copy of mpg123, so better use that one before deciding that this module is broken.




new [parameter => value, ...]


   mpg123args      an arrayreg with additional arguments for the mpg123 process
load(<path or url>) [BLOCKING]

Immediately loads the specified file (or url, http:// and file:/// forms supported) and starts playing it. If you really want to play a file with a name starting with file:// or http:// then consider prefixing all your paths with file:///. Returns a true status when the song could be started, false otherwise.


This can be used to poll the player for it's current state (playing mode, frame position &c). As every other function that requires communication with mpg123, it might take up to one frame delay until the answer returns. Using statfreq and infrequent calls to poll is often a better strategy.

pause [BLOCKING]

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

paused [CACHING]

Returns the opposite of state, i.e. zero when something is playing and non-zero when the player is stopped or paused.




Stops the currently playing song and unloads it.

statfreq(rate) [NONBLOCKING]




state [CACHING]

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>) [BLOCKING or NONBLOCKING]

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.



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.



Returns the "time per frame", i.e. the time in seconds for one frame. Useful with the jump-method:


Jumps to second 60.




Marc Lehmann <>.



syntax highlighting: