Audio-aKodePlayer

 view release on metacpan or  search on metacpan

lib/Audio/aKodePlayer.pm  view on Meta::CPAN

frame-work that provides a uniform interface to decode the most common
audio-formats such as WAV, MP3, Ogg/Vorbis, Ogg/FLAC, etc.  It also
has a direct playback option for a number of audio-outputs, such as
OSS, Alsa, SunOS/Solaris audio, Jack, and Polyp (recommended for
network transparent audio).

=head1 SYNOPSIS

  use Audio::aKodePlayer;

  my $player = Audio::aKodePlayer->new();
  $player->open('auto'); # automatically selected output sink
  $player->load( 'my_audio.ogg' ); # any format supported by aKode
  $player->play();
  $player->seek(10*1000) if $player->seekable; # seek 10 seconds from the beginning
  while (!$player->eof) {
    print "Playback position: ".($player->position()/1000)." seconds of ".($player->length()/1000)."\n";
    sleep 1;
  }
    ...
  $player->pause();
  $player->resume();
  $player->setVolume(0.75);
  print "Current volume is at ".($player->volume()*100)."%\n";
    ...
  $player->wait;   # idle until the playback stops
  $player->stop;   # stop playback
  $player->unload; # release resources related to the media
  $player->close;  # release resources related to the the output sink


=head1 EXPORT

None.

=cut

=head1 FUNCTIONS

=over 4

=item new()

Create a new Audio::aKodePlayer object.

=item open(sinkname)

Opens a player that outputs to the sink sinkname (the sink 'auto' is
recommended, other options are 'alsa', 'jack', 'oss', 'polyp', 'sun',
and maybe other, depending on the aKode installation).

Returns false if the device cannot be opened.

=item close()

Closes the player and releases the output sink.

=item load(filename)

Loads the file from a given filename and prepares it for
playing. Returns false if the file cannot be loaded or decoded.

=item setDecoderPlugin(plugin_name)

Sets the decoder plugin to use. Default is auto-detect.

=item setResamplerPlugin(plugin_name)

Sets the resampler plugin to use. Default is "fast".

=item Audio::aKodePlayer::listPlugins()

Returns the names of available plugins (as an array).

=item Audio::aKodePlayer::listSinks()

Returns the names of available sinks (as an array).

=item Audio::aKodePlayer::listDecoders()

Returns the names of available decoders (as an array).

=item unload()

Unload the file and release any resources allocated while loaded.

=item play()

Start playing.

=item stop()

Stop playing and release any resources allocated while playing.

=item wait()

Waits for the file to finish playing (eof or error) and calls
stop. This blocks the calling thread.

=item detach()

Detach the player from the current thread (once detached, you won't be
able to apply any methods on the player object).

=item pause()

Pause the player.

=item resume()

Resume the player from paused.

=item setVolume(volume)

Set the software-volume. Use a number between 0.0 and 1.0.

=item volume()

Returns the current value of the software-volume.

=item state ()



( run in 0.543 second using v1.01-cache-2.11-cpan-22024b96cdf )