App-DrivePlayer
view release on metacpan or search on metacpan
lib/App/DrivePlayer/Player.pm view on Meta::CPAN
of the form C<['Authorization', 'Bearer TOKEN']> (e.g.
L<Google::RestApi::Auth::OAuth2Client>).
=head2 on_state_change
is: ro, isa: CodeRef, optional
Called with the new state string (C<'play'>, C<'pause'>, or C<'stop'>)
whenever the playback state changes. Not called when the state is set to
its current value.
=head2 on_track_end
is: ro, isa: CodeRef, optional
Called with no arguments when a track ends naturally (EOF) or is stopped
explicitly.
=head2 on_position
is: ro, isa: CodeRef, optional
Called by L</poll> with C<($position_seconds, $duration_seconds)> when both
values are available from mpv.
=head1 METHODS
=head2 new
my $player = App::DrivePlayer::Player->new(%args);
Constructor. C<auth> is required; all callbacks are optional.
=head2 play
$player->play(\%track);
Begin playing a track. C<%track> must contain at least C<drive_id>.
Starts mpv if it is not already running. Sets state to C<'play'>.
=head2 pause_resume
$player->pause_resume;
Toggle between C<'play'> and C<'pause'>. No-op when stopped.
=head2 stop
$player->stop;
Stop playback and set state to C<'stop'>. mpv remains running.
=head2 seek
$player->seek($seconds);
Seek to an absolute position in seconds. No-op when stopped.
=head2 set_volume
$player->set_volume($percent); # 0-100
Set the playback volume.
=head2 get_volume
my $pct = $player->get_volume;
Return the current volume (0-100). Returns C<50> if mpv is not responding.
=head2 state
my $state = $player->state; # 'play', 'pause', or 'stop'
Return the current playback state.
=head2 current_track
my $track = $player->current_track; # hashref or undef
Return the track hashref passed to the most recent L</play> call.
=head2 poll
$player->poll;
Query mpv for the current playback position and duration, firing the
C<on_position> callback if both are available. Also drains any pending
mpv events. Intended to be called from a periodic GUI timer.
=head2 quit
$player->quit;
Send a quit command to mpv, wait briefly, then SIGTERM it if still
running. Closes the IPC socket. Should be called when the application
exits.
=cut
( run in 0.984 second using v1.01-cache-2.11-cpan-483215c6ad5 )