App-DrivePlayer
view release on metacpan or search on metacpan
lib/App/DrivePlayer/GUI.pm view on Meta::CPAN
}
}
sub _prev_track {
my ($self) = @_;
my $path = $self->_current_path() or return;
return unless $path->prev();
$self->_play_at_path($path);
}
# ---- Player callbacks ----
sub _on_track_end {
my ($self) = @_;
$self->_next_track();
}
sub _on_position {
my ($self, $pos, $dur) = @_;
return if $self->_progress_dragging;
$self->progress->set_range(0, $dur) if $dur;
lib/App/DrivePlayer/Player.pm view on Meta::CPAN
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
t/unit/Test/DrivePlayer/Player.pm view on Meta::CPAN
}
sub constructor_requires_auth : Tests(1) {
my ($self) = @_;
throws_ok { App::DrivePlayer::Player->new() }
qr/required/i,
'constructor requires auth';
}
sub constructor_callbacks_optional : Tests(1) {
my ($self) = @_;
lives_ok {
App::DrivePlayer::Player->new(auth => fake_auth())
} 'constructor without callbacks lives';
}
# ---- Token management ----
sub bearer_token_initial_fetch : Tests(2) {
my ($self) = @_;
my $p = fake_player(token => 'Bearer mytoken123');
my $tok = $p->_bearer_token();
is $tok, 'Bearer mytoken123', 'bearer token fetched from auth';
( run in 1.624 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )