ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MPV/MPV.pm
(Generate patch)

Comparing AnyEvent-MPV/MPV.pm (file contents):
Revision 1.16 by root, Wed Mar 22 18:17:24 2023 UTC vs.
Revision 1.18 by root, Thu Mar 23 19:22:48 2023 UTC

7 use AnyEvent::MPV; 7 use AnyEvent::MPV;
8 8
9 my $videofile = "path/to/file.mkv"; 9 my $videofile = "path/to/file.mkv";
10 use AnyEvent; 10 use AnyEvent;
11 my $mpv = AnyEvent::MPV->new (trace => 1); 11 my $mpv = AnyEvent::MPV->new (trace => 1);
12 $mpv->start; 12 $mpv->start ("--idle=yes");
13 $mpv->cmd (loadfile => $mpv->escape_binary ($videofile)); 13 $mpv->cmd (loadfile => $mpv->escape_binary ($videofile));
14 my $quit = AE::cv; 14 my $quit = AE::cv;
15 $mpv->register_event (end_file => $cv); 15 $mpv->register_event (end_file => $quit);
16 $quit->recv; 16 $quit->recv;
17
17 18
18=head1 DESCRIPTION 19=head1 DESCRIPTION
19 20
20This module allows you to remote control F<mpv> (a video player). It also 21This module allows you to remote control F<mpv> (a video player). It also
21is an L<AnyEvent> user, you need to make sure that you use and run a 22is an L<AnyEvent> user, you need to make sure that you use and run a
220use Scalar::Util (); 221use Scalar::Util ();
221 222
222use AnyEvent (); 223use AnyEvent ();
223use AnyEvent::Util (); 224use AnyEvent::Util ();
224 225
225our $VERSION = '0.2'; 226our $VERSION = '1.01';
226 227
227sub OBSID() { 0x10000000000000 } # 2**52 228sub OBSID() { 0x10000000000000 } # 2**52
228 229
229our $JSON = eval { require JSON::XS; JSON::XS:: } 230our $JSON = eval { require JSON::XS; JSON::XS:: }
230 || do { require JSON::PP; JSON::PP:: }; 231 || do { require JSON::PP; JSON::PP:: };
566For subclassing, see I<SUBCLASSING>, below. 567For subclassing, see I<SUBCLASSING>, below.
567 568
568=cut 569=cut
569 570
570sub on_event { 571sub on_event {
571 my ($self, $key) = @_; 572 my ($self, $event, $data) = @_;
572 573
573 $self->{on_event}($self, $key) if $self->{on_event}; 574 $self->{on_event}($self, $event, $data) if $self->{on_event};
574} 575}
575 576
576=item $mpv->on_key ($string) 577=item $mpv->on_key ($string)
577 578
578Invoked when a key declared by C<< ->bind_key >> is pressed. The default 579Invoked when a key declared by C<< ->bind_key >> is pressed. The default

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines