… | |
… | |
3 | AnyEvent::MPV - remote control mpv (https://mpv.io) |
3 | AnyEvent::MPV - remote control mpv (https://mpv.io) |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use AnyEvent::MPV; |
7 | use AnyEvent::MPV; |
|
|
8 | |
|
|
9 | my $videofile = "path/to/file.mkv"; |
|
|
10 | use AnyEvent; |
|
|
11 | my $mpv = AnyEvent::MPV->new (trace => 1); |
|
|
12 | $mpv->start; |
|
|
13 | $mpv->cmd (loadfile => $mpv->escape_binary ($videofile)); |
|
|
14 | my $quit = AE::cv; |
|
|
15 | $mpv->register_event (end_file => $cv); |
|
|
16 | $quit->recv; |
8 | |
17 | |
9 | =head1 DESCRIPTION |
18 | =head1 DESCRIPTION |
10 | |
19 | |
11 | This module allows you to remote control F<mpv> (a video player). It also |
20 | This module allows you to remote control F<mpv> (a video player). It also |
12 | is an L<AnyEvent> user, you need to make sure that you use and run a |
21 | is an L<AnyEvent> user, you need to make sure that you use and run a |
… | |
… | |
50 | Here is a very simple client: |
59 | Here is a very simple client: |
51 | |
60 | |
52 | use AnyEvent; |
61 | use AnyEvent; |
53 | use AnyEvent::MPV; |
62 | use AnyEvent::MPV; |
54 | |
63 | |
55 | my $videofile = "./xyzzy.mp4"; |
64 | my $videofile = "./xyzzy.mkv"; |
56 | |
65 | |
57 | my $mpv = AnyEvent::MPV->new (trace => 1); |
66 | my $mpv = AnyEvent::MPV->new (trace => 1); |
58 | |
67 | |
59 | $mpv->start ("--", $videofile); |
68 | $mpv->start ("--", $videofile); |
60 | |
69 | |
… | |
… | |
85 | shell command), so let us load the file at runtime: |
94 | shell command), so let us load the file at runtime: |
86 | |
95 | |
87 | use AnyEvent; |
96 | use AnyEvent; |
88 | use AnyEvent::MPV; |
97 | use AnyEvent::MPV; |
89 | |
98 | |
90 | my $videofile = "./xyzzy.mp4"; |
99 | my $videofile = "./xyzzy.mkv"; |
91 | |
100 | |
92 | my $mpv = AnyEvent::MPV->new ( |
101 | my $mpv = AnyEvent::MPV->new ( |
93 | trace => 1, |
102 | trace => 1, |
94 | args => ["--pause", "--idle=yes"], |
103 | args => ["--pause", "--idle=yes"], |
95 | ); |
104 | ); |
… | |
… | |
140 | receiving events (using a somewhat embellished example): |
149 | receiving events (using a somewhat embellished example): |
141 | |
150 | |
142 | use AnyEvent; |
151 | use AnyEvent; |
143 | use AnyEvent::MPV; |
152 | use AnyEvent::MPV; |
144 | |
153 | |
145 | my $videofile = "xyzzy.mp4"; |
154 | my $videofile = "xyzzy.mkv"; |
146 | |
155 | |
147 | my $quit = AE::cv; |
156 | my $quit = AE::cv; |
148 | |
157 | |
149 | my $mpv = AnyEvent::MPV->new ( |
158 | my $mpv = AnyEvent::MPV->new ( |
150 | trace => 1, |
159 | trace => 1, |
151 | args => ["--pause", "--idle=yes"], |
160 | args => ["--pause", "--idle=yes"], |
152 | on_event => sub { |
|
|
153 | my ($mpv, $event, $data) = @_; |
|
|
154 | |
|
|
155 | if ($event eq "start-file") { |
|
|
156 | $mpv->cmd ("set", "pause", "no"); |
|
|
157 | } elsif ($event eq "end-file") { |
|
|
158 | print "end-file<$data->{reason}>\n"; |
|
|
159 | $quit->send; |
|
|
160 | } |
|
|
161 | }, |
|
|
162 | ); |
161 | ); |
163 | |
162 | |
164 | $mpv->start; |
163 | $mpv->start; |
|
|
164 | |
|
|
165 | $mpv->register_event (start_file => sub { |
|
|
166 | $mpv->cmd ("set", "pause", "no"); |
|
|
167 | }); |
|
|
168 | |
|
|
169 | $mpv->register_event (end_file => sub { |
|
|
170 | my ($mpv, $event, $data) = @_; |
|
|
171 | |
|
|
172 | print "end-file<$data->{reason}>\n"; |
|
|
173 | $quit->send; |
|
|
174 | }); |
|
|
175 | |
165 | $mpv->cmd (loadfile => $mpv->escape_binary ($videofile)); |
176 | $mpv->cmd (loadfile => $mpv->escape_binary ($videofile)); |
166 | |
177 | |
167 | $quit->recv; |
178 | $quit->recv; |
168 | |
179 | |
169 | This example uses a global condvar C<$quit> to wait for the file to finish |
180 | This example uses a global condvar C<$quit> to wait for the file to finish |
170 | playing. Also, most of the logic is now in an C<on_event> callback, which |
181 | playing. Also, most of the logic is now implement in event handlers. |
171 | receives an event name and the actual event object. |
|
|
172 | |
182 | |
173 | The two events we handle are C<start-file>, which is emitted by F<mpv> |
183 | The two events handlers we register are C<start-file>, which is emitted by |
174 | once it has loaded a new file, and C<end-file>, which signals the end |
184 | F<mpv> once it has loaded a new file, and C<end-file>, which signals the |
175 | of a file. |
185 | end of a file (underscores are internally replaced by minus signs, so you |
|
|
186 | cna speicfy event names with either). |
176 | |
187 | |
177 | In the former event, we again set the C<pause> property to C<no> so the |
188 | In the C<start-file> event, we again set the C<pause> property to C<no> |
178 | movie starts playing. For the latter event, we tell the main program to |
189 | so the movie starts playing. For the C<end-file> event, we tell the main |
179 | quit by invoking C<$quit>. |
190 | program to quit by invoking C<$quit>. |
180 | |
191 | |
181 | This should conclude the basics of operation. There are a few more |
192 | This should conclude the basics of operation. There are a few more |
182 | examples later in the documentation. |
193 | examples later in the documentation. |
183 | |
194 | |
184 | =head2 ENCODING CONVENTIONS |
195 | =head2 ENCODING CONVENTIONS |
185 | |
196 | |
186 | As a rule of thumb, all data you pass to this module to be sent to F<mpv> |
197 | As a rule of thumb, all data you pass to this module to be sent to F<mpv> |
187 | is expected to be in unicode. To pass something that isn't, you need to |
198 | is expected to be in unicode. To pass something that isn't, you need to |
188 | escape it using C<escape_binary>. |
199 | escape it using C<escape_binary>. |
189 | |
200 | |
190 | Data received from C<$mpv>, however, is I<not> decoded to unicode, as data |
201 | Data received from F<mpv>, however, is I<not> decoded to unicode, as data |
191 | returned by F<mpv> is not generally encoded in unicode, and the encoding |
202 | returned by F<mpv> is not generally encoded in unicode, and the encoding |
192 | is usually unspecified. So if you receive data and expect it to be in |
203 | is usually unspecified. So if you receive data and expect it to be in |
193 | unicode, you need to first decode it from UTF-8, but note that this might |
204 | unicode, you need to first decode it from UTF-8, but note that this might |
194 | fail. This is not a limitation of this module - F<mpv> simply does not |
205 | fail. This is not a limitation of this module - F<mpv> simply does not |
195 | specify nor guarantee a specific encoding, or any encoding at all, in its |
206 | specify nor guarantee a specific encoding, or any encoding at all, in its |
… | |
… | |
216 | sub OBSID() { 0x10000000000000 } # 2**52 |
227 | sub OBSID() { 0x10000000000000 } # 2**52 |
217 | |
228 | |
218 | our $JSON = eval { require JSON::XS; JSON::XS:: } |
229 | our $JSON = eval { require JSON::XS; JSON::XS:: } |
219 | || do { require JSON::PP; JSON::PP:: }; |
230 | || do { require JSON::PP; JSON::PP:: }; |
220 | |
231 | |
221 | our $JSON_CODER = |
232 | our $JSON_ENCODER = $JSON->new->utf8; |
|
|
233 | our $JSON_DECODER = $JSON->new->latin1; |
222 | |
234 | |
223 | our $mpv_path; # last mpv path used |
235 | our $mpv_path; # last mpv path used |
224 | our $mpv_optionlist; # output of mpv --list-options |
236 | our $mpv_optionlist; # output of mpv --list-options |
225 | |
237 | |
226 | =item $mpv = AnyEvent::MPV->new (key => value...) |
238 | =item $mpv = AnyEvent::MPV->new (key => value...) |
… | |
… | |
352 | |
364 | |
353 | sub start { |
365 | sub start { |
354 | my ($self, @extra_args) = @_; |
366 | my ($self, @extra_args) = @_; |
355 | |
367 | |
356 | return 0 if $self->{fh}; |
368 | return 0 if $self->{fh}; |
357 | |
|
|
358 | $self->{obscb} = {}; |
|
|
359 | |
369 | |
360 | # cache optionlist for same "path" |
370 | # cache optionlist for same "path" |
361 | ($mpv_path, $mpv_optionlist) = ($self->{mpv}, scalar qx{\Q$self->{mpv}\E --list-options}) |
371 | ($mpv_path, $mpv_optionlist) = ($self->{mpv}, scalar qx{\Q$self->{mpv}\E --list-options}) |
362 | if $self->{mpv} ne $mpv_path; |
372 | if $self->{mpv} ne $mpv_path; |
363 | |
373 | |
… | |
… | |
400 | while ($buf =~ s/^([^\n]+)\n//) { |
410 | while ($buf =~ s/^([^\n]+)\n//) { |
401 | $trace->("mpv>" => "$1"); |
411 | $trace->("mpv>" => "$1"); |
402 | |
412 | |
403 | if ("{" eq substr $1, 0, 1) { |
413 | if ("{" eq substr $1, 0, 1) { |
404 | eval { |
414 | eval { |
405 | my $reply = $JSON->new->latin1->decode ($1); |
415 | my $reply = $JSON_DECODER->decode ($1); |
406 | |
416 | |
407 | if (exists $reply->{event}) { |
417 | if (defined (my $event = delete $reply->{event})) { |
408 | if ( |
418 | if ( |
409 | $reply->{event} eq "client-message" |
419 | $event eq "client-message" |
410 | and $reply->{args}[0] eq "AnyEvent::MPV" |
420 | and $reply->{args}[0] eq "AnyEvent::MPV" |
411 | ) { |
421 | ) { |
412 | if ($reply->{args}[1] eq "key") { |
422 | if ($reply->{args}[1] eq "key") { |
413 | (my $key = $reply->{args}[2]) =~ s/\\x(..)/chr hex $1/ge; |
423 | (my $key = $reply->{args}[2]) =~ s/\\x(..)/chr hex $1/ge; |
414 | $self->on_key ($key); |
424 | $self->on_key ($key); |
415 | } |
425 | } |
416 | } elsif ( |
426 | } elsif ( |
417 | $reply->{event} eq "property-change" |
427 | $event eq "property-change" |
418 | and OBSID <= $reply->{id} |
428 | and OBSID <= $reply->{id} |
419 | ) { |
429 | ) { |
420 | if (my $cb = $self->{obscb}{$reply->{id}}) { |
430 | if (my $cb = $self->{obscb}{$reply->{id}}) { |
421 | $cb->($self, $reply->{name}, $reply->{data}); |
431 | $cb->($self, $event, $reply->{data}); |
422 | } |
432 | } |
423 | } else { |
433 | } else { |
|
|
434 | if (my $cbs = $self->{evtcb}{$event}) { |
|
|
435 | for my $evtid (keys %$cbs) { |
|
|
436 | my $cb = $cbs->{$evtid} |
|
|
437 | or next; |
|
|
438 | $cb->($self, $event, $reply); |
|
|
439 | } |
|
|
440 | } |
|
|
441 | |
424 | $self->on_event (delete $reply->{event}, $reply); |
442 | $self->on_event ($event, $reply); |
425 | } |
443 | } |
426 | } elsif (exists $reply->{request_id}) { |
444 | } elsif (exists $reply->{request_id}) { |
427 | my $cv = delete $self->{cmdcv}{$reply->{request_id}}; |
445 | my $cv = delete $self->{cmdcv}{$reply->{request_id}}; |
428 | |
446 | |
429 | unless ($cv) { |
447 | unless ($cv) { |
… | |
… | |
460 | $self->{_cmd} = sub { |
478 | $self->{_cmd} = sub { |
461 | my $cv = AE::cv; |
479 | my $cv = AE::cv; |
462 | |
480 | |
463 | $self->{cmdcv}{++$reqid} = $cv; |
481 | $self->{cmdcv}{++$reqid} = $cv; |
464 | |
482 | |
465 | my $cmd = $JSON->new->utf8->encode ({ command => ref $_[0] ? $_[0] : \@_, request_id => $reqid*1 }); |
483 | my $cmd = $JSON_ENCODER->encode ({ command => ref $_[0] ? $_[0] : \@_, request_id => $reqid*1 }); |
466 | |
484 | |
467 | # (un-)apply escape_binary hack |
485 | # (un-)apply escape_binary hack |
468 | $cmd =~ s/\xf4\x8e\x97\x9f(..)/sprintf sprintf "\\x%02x", hex $1/ges; # f48e979f == 10e5df in utf-8 |
486 | $cmd =~ s/\xf4\x8e\x97\x9f(..)/sprintf sprintf "\\x%02x", hex $1/ges; # f48e979f == 10e5df in utf-8 |
469 | |
487 | |
470 | $trace->(">mpv" => $cmd); |
488 | $trace->(">mpv" => $cmd); |
… | |
… | |
508 | |
526 | |
509 | } |
527 | } |
510 | |
528 | |
511 | delete $self->{pid}; |
529 | delete $self->{pid}; |
512 | delete $self->{cmdcv}; |
530 | delete $self->{cmdcv}; |
|
|
531 | delete $self->{evtid}; |
|
|
532 | delete $self->{evtcb}; |
513 | delete $self->{obsid}; |
533 | delete $self->{obsid}; |
514 | delete $self->{obscb}; |
534 | delete $self->{obscb}; |
515 | delete $self->{wbuf}; |
535 | delete $self->{wbuf}; |
516 | } |
536 | } |
517 | |
537 | |
… | |
… | |
630 | &cmd->recv |
650 | &cmd->recv |
631 | } |
651 | } |
632 | |
652 | |
633 | =item $mpv->bind_key ($INPUT => $string) |
653 | =item $mpv->bind_key ($INPUT => $string) |
634 | |
654 | |
635 | This is an extension implement by this module to make it easy to get key events. The way this is implemented |
655 | This is an extension implement by this module to make it easy to get key |
636 | is to bind a C<client-message> witha first argument of C<AnyEvent::MPV> and the C<$string> you passed. This C<$string> is then |
656 | events. The way this is implemented is to bind a C<client-message> witha |
637 | passed to the C<on_key> handle when the key is proessed, e.g.: |
657 | first argument of C<AnyEvent::MPV> and the C<$string> you passed. This |
|
|
658 | C<$string> is then passed to the C<on_key> handle when the key is |
|
|
659 | proessed, e.g.: |
638 | |
660 | |
639 | my $mpv = AnyEvent::MPV->new ( |
661 | my $mpv = AnyEvent::MPV->new ( |
640 | on_key => sub { |
662 | on_key => sub { |
641 | my ($mpv, $key) = @_; |
663 | my ($mpv, $key) = @_; |
642 | |
664 | |
… | |
… | |
646 | }, |
668 | }, |
647 | ); |
669 | ); |
648 | |
670 | |
649 | $mpv_>bind_key (ESC => "letmeout"); |
671 | $mpv_>bind_key (ESC => "letmeout"); |
650 | |
672 | |
|
|
673 | You cna find a list of key names L<in the mpv |
|
|
674 | documentation|https://mpv.io/manual/stable/#key-names>. |
|
|
675 | |
651 | The key configuration is lost when F<mpv> is stopped and must be (re-)done |
676 | The key configuration is lost when F<mpv> is stopped and must be (re-)done |
652 | after every C<start>. |
677 | after every C<start>. |
653 | |
678 | |
654 | =cut |
679 | =cut |
655 | |
680 | |
… | |
… | |
658 | |
683 | |
659 | $event =~ s/([^A-Za-z0-9\-_])/sprintf "\\x%02x", ord $1/ge; |
684 | $event =~ s/([^A-Za-z0-9\-_])/sprintf "\\x%02x", ord $1/ge; |
660 | $self->cmd (keybind => $key => "no-osd script-message AnyEvent::MPV key $event"); |
685 | $self->cmd (keybind => $key => "no-osd script-message AnyEvent::MPV key $event"); |
661 | } |
686 | } |
662 | |
687 | |
|
|
688 | =item [$guard] = $mpv->register_event ($event => $coderef->($mpv, $event, $data)) |
|
|
689 | |
|
|
690 | This method registers a callback to be invoked for a specific |
|
|
691 | event. Whenever the event occurs, it calls the coderef with the C<$mpv> |
|
|
692 | object, the C<$event> name and the event object, just like the C<on_event> |
|
|
693 | method. |
|
|
694 | |
|
|
695 | For a lst of events, see L<the mpv |
|
|
696 | documentation|https://mpv.io/manual/stable/#list-of-events>. Any |
|
|
697 | underscore in the event name is replaced by a minus sign, so you can |
|
|
698 | specify event names using underscores for easier quoting in Perl. |
|
|
699 | |
|
|
700 | In void context, the handler stays registered until C<stop> is called. In |
|
|
701 | any other context, it returns a guard object that, when destroyed, will |
|
|
702 | unregister the handler. |
|
|
703 | |
|
|
704 | You can register multiple handlers for the same event, and this method |
|
|
705 | does not interfere with the C<on_event> mechanism. That is, you can |
|
|
706 | completely ignore this method and handle events in a C<on_event> handler, |
|
|
707 | or mix both approaches as you see fit. |
|
|
708 | |
|
|
709 | Note that unlike commands, event handlers are registered immediately, that |
|
|
710 | is, you can issue a command, then register an event handler and then get |
|
|
711 | an event for this handler I<before> the command is even sent to F<mpv>. If |
|
|
712 | this kind of race is an issue, you can issue a dummy command such as |
|
|
713 | C<get_version> and register the handler when the reply is received. |
|
|
714 | |
|
|
715 | =cut |
|
|
716 | |
663 | sub AnyEvent::MPV::Unobserve::DESTROY { |
717 | sub AnyEvent::MPV::Unevent::DESTROY { |
664 | my ($mpv, $obscb, $obsid) = @{$_[0]}; |
718 | my ($evtcb, $event, $evtid) = @{$_[0]}; |
|
|
719 | delete $evtcb->{$event}{$evtid}; |
|
|
720 | } |
665 | |
721 | |
666 | delete $obscb->{$obsid}; |
722 | sub register_event { |
|
|
723 | my ($self, $event, $cb) = @_; |
667 | |
724 | |
668 | if ($obscb == $mpv->{obscb}) { |
725 | $event =~ y/_/-/; |
669 | $mpv->cmd (unobserve_property => $obsid+0); |
726 | |
670 | } |
727 | my $evtid = ++$self->{evtid}; |
|
|
728 | $self->{evtcb}{$event}{$evtid} = $cb; |
|
|
729 | |
|
|
730 | defined wantarray |
|
|
731 | and bless [$self->{evtcb}, $event, $evtid], AnyEvent::MPV::Unevent:: |
671 | } |
732 | } |
672 | |
733 | |
673 | =item [$guard] = $mpv->observe_property ($name => $coderef->($mpv, $name, $value)) |
734 | =item [$guard] = $mpv->observe_property ($name => $coderef->($mpv, $name, $value)) |
674 | |
735 | |
675 | =item [$guard] = $mpv->observe_property_string ($name => $coderef->($mpv, $name, $value)) |
736 | =item [$guard] = $mpv->observe_property_string ($name => $coderef->($mpv, $name, $value)) |
… | |
… | |
718 | |
779 | |
719 | () # ensure the above method is called in void context |
780 | () # ensure the above method is called in void context |
720 | } |
781 | } |
721 | |
782 | |
722 | =cut |
783 | =cut |
|
|
784 | |
|
|
785 | sub AnyEvent::MPV::Unobserve::DESTROY { |
|
|
786 | my ($mpv, $obscb, $obsid) = @{$_[0]}; |
|
|
787 | |
|
|
788 | delete $obscb->{$obsid}; |
|
|
789 | |
|
|
790 | if ($obscb == $mpv->{obscb}) { |
|
|
791 | $mpv->cmd (unobserve_property => $obsid+0); |
|
|
792 | } |
|
|
793 | } |
723 | |
794 | |
724 | sub _observe_property { |
795 | sub _observe_property { |
725 | my ($self, $type, $property, $cb) = @_; |
796 | my ($self, $type, $property, $cb) = @_; |
726 | |
797 | |
727 | my $obsid = OBSID + ++$self->{obsid}; |
798 | my $obsid = OBSID + ++$self->{obsid}; |
… | |
… | |
760 | care and deal with the breakage. |
831 | care and deal with the breakage. |
761 | |
832 | |
762 | If you don't want to go to the effort of subclassing this module, you can |
833 | If you don't want to go to the effort of subclassing this module, you can |
763 | also specify all event handlers as constructor keys. |
834 | also specify all event handlers as constructor keys. |
764 | |
835 | |
|
|
836 | =head1 EXAMPLES |
|
|
837 | |
|
|
838 | Here are some real-world code snippets, thrown in here mainly to give you |
|
|
839 | some example code to copy. |
|
|
840 | |
|
|
841 | =head2 doomfrontend |
|
|
842 | |
|
|
843 | At one point I replaced mythtv-frontend by my own terminal-based video |
|
|
844 | player (based on rxvt-unicode). I toyed with the diea of using F<mpv>'s |
|
|
845 | subtitle engine to create the user interface, but that is hard to use |
|
|
846 | since you don't know how big your letters are. It is also where most of |
|
|
847 | this modules code has originally been developed in. |
|
|
848 | |
|
|
849 | It uses a unified input queue to handle various remote controls, so its |
|
|
850 | event handling needs are very simple - it simply feeds all events into the |
|
|
851 | input queue: |
|
|
852 | |
|
|
853 | my $mpv = AnyEvent::MPV->new ( |
|
|
854 | mpv => $MPV, |
|
|
855 | args => \@MPV_ARGS, |
|
|
856 | on_event => sub { |
|
|
857 | input_feed "mpv/$_[1]", $_[2]; |
|
|
858 | }, |
|
|
859 | on_key => sub { |
|
|
860 | input_feed $_[1]; |
|
|
861 | }, |
|
|
862 | on_eof => sub { |
|
|
863 | input_feed "mpv/quit"; |
|
|
864 | }, |
|
|
865 | ); |
|
|
866 | |
|
|
867 | ... |
|
|
868 | |
|
|
869 | $mpv->start ("--idle=yes", "--pause", "--force-window=no"); |
|
|
870 | |
|
|
871 | It also doesn't use complicated command line arguments - the file search |
|
|
872 | options have the most impact, as they prevent F<mpv> from scanning |
|
|
873 | directories with tens of thousands of files for subtitles and more: |
|
|
874 | |
|
|
875 | --audio-client-name=doomfrontend |
|
|
876 | --osd-on-seek=msg-bar --osd-bar-align-y=-0.85 --osd-bar-w=95 |
|
|
877 | --sub-auto=exact --audio-file-auto=exact |
|
|
878 | |
|
|
879 | Since it runs on a TV without a desktop environemnt, it tries to keep complications such as dbus |
|
|
880 | away and the screensaver happy: |
|
|
881 | |
|
|
882 | # prevent xscreensaver from doing something stupid, such as starting dbus |
|
|
883 | $ENV{DBUS_SESSION_BUS_ADDRESS} = "/"; # prevent dbus autostart for sure |
|
|
884 | $ENV{XDG_CURRENT_DESKTOP} = "generic"; |
|
|
885 | |
|
|
886 | It does bind a number of keys to internal (to doomfrontend) commands: |
|
|
887 | |
|
|
888 | for ( |
|
|
889 | List::Util::pairs qw( |
|
|
890 | ESC return |
|
|
891 | q return |
|
|
892 | ENTER enter |
|
|
893 | SPACE pause |
|
|
894 | [ steprev |
|
|
895 | ] stepfwd |
|
|
896 | j subtitle |
|
|
897 | BS red |
|
|
898 | i green |
|
|
899 | o yellow |
|
|
900 | b blue |
|
|
901 | D triangle |
|
|
902 | UP up |
|
|
903 | DOWN down |
|
|
904 | RIGHT right |
|
|
905 | LEFT left |
|
|
906 | ), |
|
|
907 | (map { ("KP$_" => "num$_") } 0..9), |
|
|
908 | KP_INS => 0, # KP0, but different |
|
|
909 | ) { |
|
|
910 | $mpv->bind_key ($_->[0] => $_->[1]); |
|
|
911 | } |
|
|
912 | |
|
|
913 | It also reacts to sponsorblock chapters, so it needs to know when vidoe |
|
|
914 | chapters change. Preadting C<AnyEvent::MPV>, it handles observers |
|
|
915 | manually: |
|
|
916 | |
|
|
917 | $mpv->cmd (observe_property => 1, "chapter-metadata"); |
|
|
918 | |
|
|
919 | It also tries to apply an F<mpv> profile, if it exists: |
|
|
920 | |
|
|
921 | eval { |
|
|
922 | # the profile is optional |
|
|
923 | $mpv->cmd ("apply-profile" => "doomfrontend"); |
|
|
924 | }; |
|
|
925 | |
|
|
926 | Most of the complicated parts deal with saving and restoring per-video |
|
|
927 | data, such as bookmarks, playing position, selected audio and subtitle |
|
|
928 | tracks and so on. However, since it uses L<Coro>, it can conveniently |
|
|
929 | block and wait for replies, which is n ot possible in purely event based |
|
|
930 | programs, as you are not allowed to block inside event callbacks in most |
|
|
931 | event loops. This simplifies the code quite a bit. |
|
|
932 | |
|
|
933 | When the file to be played is a Tv recording done by mythtv, it uses the |
|
|
934 | C<appending> protocol and deinterlacing: |
|
|
935 | |
|
|
936 | if (is_myth $mpv_path) { |
|
|
937 | $mpv_path = "appending://$mpv_path"; |
|
|
938 | $initial_deinterlace = 1; |
|
|
939 | } |
|
|
940 | |
|
|
941 | Otherwise, it sets some defaults and loads the file (I forgot what the |
|
|
942 | C<dummy> argument is for, but I am sure it is needed by some F<mpv> |
|
|
943 | version): |
|
|
944 | |
|
|
945 | $mpv->cmd ("script-message", "osc-visibility", "never", "dummy"); |
|
|
946 | $mpv->cmd ("set", "vid", "auto"); |
|
|
947 | $mpv->cmd ("set", "aid", "auto"); |
|
|
948 | $mpv->cmd ("set", "sid", "no"); |
|
|
949 | $mpv->cmd ("set", "file-local-options/chapters-file", $mpv->escape_binary ("$mpv_path.chapters")); |
|
|
950 | $mpv->cmd ("loadfile", $mpv->escape_binary ($mpv_path)); |
|
|
951 | $mpv->cmd ("script-message", "osc-visibility", "auto", "dummy"); |
|
|
952 | |
|
|
953 | Handling events makes the main bulk of video playback code. For example, |
|
|
954 | various ways of ending playback: |
|
|
955 | |
|
|
956 | if ($INPUT eq "mpv/quit") { # should not happen, but allows user to kill etc. without consequence |
|
|
957 | $status = 1; |
|
|
958 | mpv_init; # try reinit |
|
|
959 | last; |
|
|
960 | |
|
|
961 | } elsif ($INPUT eq "mpv/idle") { # normal end-of-file |
|
|
962 | last; |
|
|
963 | |
|
|
964 | } elsif ($INPUT eq "return") { |
|
|
965 | $status = 1; |
|
|
966 | last; |
|
|
967 | |
|
|
968 | Or the code that actually starts playback, once the file is loaded: |
|
|
969 | |
|
|
970 | our %SAVE_PROPERTY = (aid => 1, sid => 1, "audio-delay" => 1); |
|
|
971 | |
|
|
972 | ... |
|
|
973 | |
|
|
974 | my $oid = 100; |
|
|
975 | |
|
|
976 | } elsif ($INPUT eq "mpv/file-loaded") { # start playing, configure video |
|
|
977 | $mpv->cmd ("seek", $playback_start, "absolute+exact") if $playback_start > 0; |
|
|
978 | |
|
|
979 | my $target_fps = eval { $mpv->cmd_recv ("get_property", "container-fps") } || 60; |
|
|
980 | $target_fps *= play_video_speed_mult; |
|
|
981 | set_fps $target_fps; |
|
|
982 | |
|
|
983 | unless (eval { $mpv->cmd_recv ("get_property", "video-format") }) { |
|
|
984 | $mpv->cmd ("set", "file-local-options/lavfi-complex", "[aid1] asplit [ao], showcqt=..., format=yuv420p [vo]"); |
|
|
985 | }; |
|
|
986 | |
|
|
987 | for my $prop (keys %SAVE_PROPERTY) { |
|
|
988 | if (exists $PLAYING_STATE->{"mpv_$prop"}) { |
|
|
989 | $mpv->cmd ("set", "$prop", $PLAYING_STATE->{"mpv_$prop"} . ""); |
|
|
990 | } |
|
|
991 | |
|
|
992 | $mpv->cmd ("observe_property", ++$oid, $prop); |
|
|
993 | } |
|
|
994 | |
|
|
995 | play_video_set_speed; |
|
|
996 | $mpv->cmd ("set", "osd-level", "$OSD_LEVEL"); |
|
|
997 | $mpv->cmd ("observe_property", ++$oid, "osd-level"); |
|
|
998 | $mpv->cmd ("set", "pause", "no"); |
|
|
999 | |
|
|
1000 | $mpv->cmd ("set_property", "deinterlace", "yes") |
|
|
1001 | if $initial_deinterlace; |
|
|
1002 | |
|
|
1003 | There is a lot going on here. First it seeks to the actual playback |
|
|
1004 | position, if it is not at the start of the file (it would probaby be more |
|
|
1005 | efficient to set the starting position before loading the file, though, |
|
|
1006 | but this is good enough). |
|
|
1007 | |
|
|
1008 | Then it plays with the display fps, to set it to something harmonious |
|
|
1009 | w.r.t. the video framerate. |
|
|
1010 | |
|
|
1011 | If the file does not have a video part, it assumes it is an audio file and |
|
|
1012 | sets a visualizer. |
|
|
1013 | |
|
|
1014 | Also, a number of properties are not global, but per-file. At the moment, |
|
|
1015 | this is C<audio-delay>, and the current audio/subtitle track, which it |
|
|
1016 | sets, and also creates an observer. Again, this doesn'T use the observe |
|
|
1017 | functionality of this module, but handles it itself, assigning obsevrer |
|
|
1018 | ids 100+ to temporary/per-file observers. |
|
|
1019 | |
|
|
1020 | Lastly, it sets some global (or per-youtube-uploader) parameters, such as |
|
|
1021 | speed, and unpauses. Property changes are handled like other input events: |
|
|
1022 | |
|
|
1023 | } elsif ($INPUT eq "mpv/property-change") { |
|
|
1024 | my $prop = $INPUT_DATA->{name}; |
|
|
1025 | |
|
|
1026 | if ($prop eq "chapter-metadata") { |
|
|
1027 | if ($INPUT_DATA->{data}{TITLE} =~ /^\[SponsorBlock\]: (.*)/) { |
|
|
1028 | my $section = $1; |
|
|
1029 | my $skip; |
|
|
1030 | |
|
|
1031 | $skip ||= $SPONSOR_SKIP{$_} |
|
|
1032 | for split /\s*,\s*/, $section; |
|
|
1033 | |
|
|
1034 | if (defined $skip) { |
|
|
1035 | if ($skip) { |
|
|
1036 | # delay a bit, in case we get two metadata changes in quick succession, e.g. |
|
|
1037 | # because we have a skip at file load time. |
|
|
1038 | $skip_delay = AE::timer 2/50, 0, sub { |
|
|
1039 | $mpv->cmd ("no-osd", "add", "chapter", 1); |
|
|
1040 | $mpv->cmd ("show-text", "skipped sponsorblock section \"$section\"", 3000); |
|
|
1041 | }; |
|
|
1042 | } else { |
|
|
1043 | undef $skip_delay; |
|
|
1044 | $mpv->cmd ("show-text", "NOT skipping sponsorblock section \"$section\"", 3000); |
|
|
1045 | } |
|
|
1046 | } else { |
|
|
1047 | $mpv->cmd ("show-text", "UNRECOGNIZED sponsorblock section \"$section\"", 60000); |
|
|
1048 | } |
|
|
1049 | } else { |
|
|
1050 | # cancel a queued skip |
|
|
1051 | undef $skip_delay; |
|
|
1052 | } |
|
|
1053 | |
|
|
1054 | } elsif (exists $SAVE_PROPERTY{$prop}) { |
|
|
1055 | $PLAYING_STATE->{"mpv_$prop"} = $INPUT_DATA->{data}; |
|
|
1056 | ::state_save; |
|
|
1057 | } |
|
|
1058 | |
|
|
1059 | This saves back the per-file properties, and also handles chapter changes |
|
|
1060 | in a hacky way. |
|
|
1061 | |
|
|
1062 | Most of the handlers are very simple, though. For example: |
|
|
1063 | |
|
|
1064 | } elsif ($INPUT eq "pause") { |
|
|
1065 | $mpv->cmd ("cycle", "pause"); |
|
|
1066 | $PLAYING_STATE->{curpos} = $mpv->cmd_recv ("get_property", "playback-time"); |
|
|
1067 | } elsif ($INPUT eq "right") { |
|
|
1068 | $mpv->cmd ("osd-msg-bar", "seek", 30, "relative+exact"); |
|
|
1069 | } elsif ($INPUT eq "left") { |
|
|
1070 | $mpv->cmd ("osd-msg-bar", "seek", -5, "relative+exact"); |
|
|
1071 | } elsif ($INPUT eq "up") { |
|
|
1072 | $mpv->cmd ("osd-msg-bar", "seek", +600, "relative+exact"); |
|
|
1073 | } elsif ($INPUT eq "down") { |
|
|
1074 | $mpv->cmd ("osd-msg-bar", "seek", -600, "relative+exact"); |
|
|
1075 | } elsif ($INPUT eq "select") { |
|
|
1076 | $mpv->cmd ("osd-msg-bar", "add", "audio-delay", "-0.100"); |
|
|
1077 | } elsif ($INPUT eq "start") { |
|
|
1078 | $mpv->cmd ("osd-msg-bar", "add", "audio-delay", "0.100"); |
|
|
1079 | } elsif ($INPUT eq "intfwd") { |
|
|
1080 | $mpv->cmd ("no-osd", "frame-step"); |
|
|
1081 | } elsif ($INPUT eq "audio") { |
|
|
1082 | $mpv->cmd ("osd-auto", "cycle", "audio"); |
|
|
1083 | } elsif ($INPUT eq "subtitle") { |
|
|
1084 | $mpv->cmd ("osd-auto", "cycle", "sub"); |
|
|
1085 | } elsif ($INPUT eq "triangle") { |
|
|
1086 | $mpv->cmd ("osd-auto", "cycle", "deinterlace"); |
|
|
1087 | |
|
|
1088 | Once a file has finished playing (or the user strops playback), it pauses, |
|
|
1089 | unobserves the per-file observers, and saves the current position for to |
|
|
1090 | be able to resume: |
|
|
1091 | |
|
|
1092 | $mpv->cmd ("set", "pause", "yes"); |
|
|
1093 | |
|
|
1094 | while ($oid > 100) { |
|
|
1095 | $mpv->cmd ("unobserve_property", $oid--); |
|
|
1096 | } |
|
|
1097 | |
|
|
1098 | $PLAYING_STATE->{curpos} = $mpv->cmd_recv ("get_property", "playback-time"); |
|
|
1099 | |
|
|
1100 | And thats most of the F<mpv>-related code. |
|
|
1101 | |
|
|
1102 | =head2 F<Gtk2::CV> |
|
|
1103 | |
|
|
1104 | F<Gtk2::CV> is low-feature image viewer that I use many times daily |
|
|
1105 | because it can handle directories with millions of files without falling |
|
|
1106 | over. It also had the ability to play videos for ages, but it used an |
|
|
1107 | older, crappier protocol to talk to F<mpv> and used F<ffprobe> before |
|
|
1108 | playing each file instead of letting F<mpv> handle format/size detection. |
|
|
1109 | |
|
|
1110 | After writing this module, I decided to upgprade Gtk2::CV by making use |
|
|
1111 | of it, with the goal of getting rid of F<ffprobe> and being ablew to |
|
|
1112 | reuse F<mpv> processes, which would have a multitude of speed benefits |
|
|
1113 | (for example, fork+exec of F<mpv> caused the kernel to close all file |
|
|
1114 | descriptors, which could take minutes if a large file was being copied via |
|
|
1115 | NFS, as the kernel waited for thr buffers to be flushed on close - not |
|
|
1116 | having to start F<mpv> gets rid of this issue). |
|
|
1117 | |
|
|
1118 | Setting up is only complicated by the fact that F<mpv> needs to be |
|
|
1119 | embedded into an existing window. To keep control of all inputs, |
|
|
1120 | F<Gtk2::CV> puts an eventbox in front of F<mpv>, so F<mpv> receives no |
|
|
1121 | input events: |
|
|
1122 | |
|
|
1123 | $self->{mpv} = AnyEvent::MPV->new ( |
|
|
1124 | trace => $ENV{CV_MPV_TRACE}, |
|
|
1125 | ); |
|
|
1126 | |
|
|
1127 | # create an eventbox, so we receive all input events |
|
|
1128 | my $box = $self->{mpv_eventbox} = new Gtk2::EventBox; |
|
|
1129 | $box->set_above_child (1); |
|
|
1130 | $box->set_visible_window (0); |
|
|
1131 | $box->set_events ([]); |
|
|
1132 | $box->can_focus (0); |
|
|
1133 | |
|
|
1134 | # create a drawingarea that mpv can display into |
|
|
1135 | my $window = $self->{mpv_window} = new Gtk2::DrawingArea; |
|
|
1136 | $box->add ($window); |
|
|
1137 | |
|
|
1138 | # put the drawingarea intot he eventbox, and the eventbox into our display window |
|
|
1139 | $self->add ($box); |
|
|
1140 | |
|
|
1141 | # we need to pass the window id to F<mpv>, which means we need to realise |
|
|
1142 | # the drawingarea, so an X window is allocated for it. |
|
|
1143 | $self->show_all; |
|
|
1144 | $window->realize; |
|
|
1145 | my $xid = $window->window->get_xid; |
|
|
1146 | |
|
|
1147 | Then it starts F<mpv> using this setup: |
|
|
1148 | |
|
|
1149 | local $ENV{LC_ALL} = "POSIX"; |
|
|
1150 | $self->{mpv}->start ( |
|
|
1151 | "--no-terminal", |
|
|
1152 | "--no-input-terminal", |
|
|
1153 | "--no-input-default-bindings", |
|
|
1154 | "--no-input-cursor", |
|
|
1155 | "--input-conf=/dev/null", |
|
|
1156 | "--input-vo-keyboard=no", |
|
|
1157 | |
|
|
1158 | "--loop-file=inf", |
|
|
1159 | "--force-window=yes", |
|
|
1160 | "--idle=yes", |
|
|
1161 | |
|
|
1162 | "--audio-client-name=CV", |
|
|
1163 | |
|
|
1164 | "--osc=yes", # --osc=no displays fading play/pause buttons instead |
|
|
1165 | |
|
|
1166 | "--wid=$xid", |
|
|
1167 | ); |
|
|
1168 | |
|
|
1169 | $self->{mpv}->cmd ("script-message" => "osc-visibility" => "never", "dummy"); |
|
|
1170 | $self->{mpv}->cmd ("osc-idlescreen" => "no"); |
|
|
1171 | |
|
|
1172 | It also prepares a hack to force a ConfigureNotify event on every vidoe |
|
|
1173 | reconfig: |
|
|
1174 | |
|
|
1175 | # force a configurenotify on every video-reconfig |
|
|
1176 | $self->{mpv_reconfig} = $self->{mpv}->register_event (video_reconfig => sub { |
|
|
1177 | my ($mpv, $event, $data) = @_; |
|
|
1178 | |
|
|
1179 | $self->mpv_window_update; |
|
|
1180 | }); |
|
|
1181 | |
|
|
1182 | The way this is done is by doing a "dummy" resize to 1x1 and back: |
|
|
1183 | |
|
|
1184 | $self->{mpv_window}->window->resize (1, 1), |
|
|
1185 | $self->{mpv_window}->window->resize ($self->{w}, $self->{h}); |
|
|
1186 | |
|
|
1187 | Without this, F<mpv> often doesn't "get" the correct window size. Doing |
|
|
1188 | it this way is not nice, but I didn't fine a nicer way to do it. |
|
|
1189 | |
|
|
1190 | When no file is being played, F<mpv> is hidden and prepared: |
|
|
1191 | |
|
|
1192 | $self->{mpv_eventbox}->hide; |
|
|
1193 | |
|
|
1194 | $self->{mpv}->cmd (set_property => "pause" => "yes"); |
|
|
1195 | $self->{mpv}->cmd ("playlist_remove", "current"); |
|
|
1196 | $self->{mpv}->cmd (set_property => "video-rotate" => 0); |
|
|
1197 | $self->{mpv}->cmd (set_property => "lavfi-complex" => ""); |
|
|
1198 | |
|
|
1199 | Loading a file is a bit more complicated, as bluray and DVD rips are |
|
|
1200 | supported: |
|
|
1201 | |
|
|
1202 | if ($moviedir) { |
|
|
1203 | if ($moviedir eq "br") { |
|
|
1204 | $mpv->cmd (set => "bluray-device" => $path); |
|
|
1205 | $mpv->cmd (loadfile => "bd://"); |
|
|
1206 | } elsif ($moviedir eq "dvd") { |
|
|
1207 | $mpv->cmd (set => "dvd-device" => $path); |
|
|
1208 | $mpv->cmd (loadfile => "dvd://"); |
|
|
1209 | } |
|
|
1210 | } elsif ($type eq "video/iso-bluray") { |
|
|
1211 | $mpv->cmd (set => "bluray-device" => $path); |
|
|
1212 | $mpv->cmd (loadfile => "bd://"); |
|
|
1213 | } else { |
|
|
1214 | $mpv->cmd (loadfile => $mpv->escape_binary ($path)); |
|
|
1215 | } |
|
|
1216 | |
|
|
1217 | After this, C<Gtk2::CV> waits for the file to be loaded, video to be |
|
|
1218 | configured, and then queries the video size (to resize its own window) |
|
|
1219 | and video format (to decide whether an audio visualizer is needed for |
|
|
1220 | audio playback). The problematic word here is "wait", as this needs to be |
|
|
1221 | imploemented using callbacks. |
|
|
1222 | |
|
|
1223 | This made the code much harder to write, as the whole setup is very |
|
|
1224 | asynchronous (C<Gtk2::CV> talks to the command interface in F<mpv>, which |
|
|
1225 | talks to the decode and playback parts, all of which run asynchronously |
|
|
1226 | w.r.t. each other. In practise, this can mean that C<Gtk2::CV> waits for |
|
|
1227 | a file to be loaded by F<mpv> while the command interface of F<mpv> still |
|
|
1228 | deals with the previous file and the decoder still handles an even older |
|
|
1229 | file). Adding to this fact is that Gtk2::CV is bound by the glib event |
|
|
1230 | loop, which means we cannot wait for replies form F<mpv> anywhere, so |
|
|
1231 | everything has to be chained callbacks. |
|
|
1232 | |
|
|
1233 | The way this is handled is by creating a new empty hash ref that is unique |
|
|
1234 | for each loaded file, and use it to detect whether the event is old or |
|
|
1235 | not, and also store C<AnyEvent::MPV> guard objects in it: |
|
|
1236 | |
|
|
1237 | # every time we loaded a file, we create a new hash |
|
|
1238 | my $guards = $self->{mpv_guards} = { }; |
|
|
1239 | |
|
|
1240 | Then, when we wait for an event to occur, delete the handler, and, if the |
|
|
1241 | C<mpv_guards> object has changed, we ignore it. Something like this: |
|
|
1242 | |
|
|
1243 | $guards->{file_loaded} = $mpv->register_event (file_loaded => sub { |
|
|
1244 | delete $guards->{file_loaded}; |
|
|
1245 | return if $guards != $self->{mpv_guards}; |
|
|
1246 | |
|
|
1247 | Commands do not have guards since they cnanot be cancelled, so we don't |
|
|
1248 | have to do this for commands. But what prevents us form misinterpreting |
|
|
1249 | an old event? Since F<mpv> (by default) handles commands synchronously, |
|
|
1250 | we can queue a dummy command, whose only purpose is to tell us when all |
|
|
1251 | previous commands are done. We use C<get_version> for this. |
|
|
1252 | |
|
|
1253 | The simplified code looks like this: |
|
|
1254 | |
|
|
1255 | Scalar::Util::weaken $self; |
|
|
1256 | |
|
|
1257 | $mpv->cmd ("get_version")->cb (sub { |
|
|
1258 | |
|
|
1259 | $guards->{file_loaded} = $mpv->register_event (file_loaded => sub { |
|
|
1260 | delete $guards->{file_loaded}; |
|
|
1261 | return if $guards != $self->{mpv_guards}; |
|
|
1262 | |
|
|
1263 | $mpv->cmd (get_property => "video-format")->cb (sub { |
|
|
1264 | return if $guards != $self->{mpv_guards}; |
|
|
1265 | |
|
|
1266 | # video-format handling |
|
|
1267 | return if eval { $_[0]->recv; 1 }; |
|
|
1268 | |
|
|
1269 | # no video? assume audio and visualize, cpu usage be damned |
|
|
1270 | $mpv->cmd (set => "lavfi-complex" => ..."); |
|
|
1271 | }); |
|
|
1272 | |
|
|
1273 | $guards->{show} = $mpv->register_event (video_reconfig => sub { |
|
|
1274 | delete $guards->{show}; |
|
|
1275 | return if $guards != $self->{mpv_guards}; |
|
|
1276 | |
|
|
1277 | $self->{mpv_eventbox}->show_all; |
|
|
1278 | |
|
|
1279 | $w = $mpv->cmd (get_property => "dwidth"); |
|
|
1280 | $h = $mpv->cmd (get_property => "dheight"); |
|
|
1281 | |
|
|
1282 | $h->cb (sub { |
|
|
1283 | $w = eval { $w->recv }; |
|
|
1284 | $h = eval { $h->recv }; |
|
|
1285 | |
|
|
1286 | $mpv->cmd (set_property => "pause" => "no"); |
|
|
1287 | |
|
|
1288 | if ($w && $h) { |
|
|
1289 | # resize our window |
|
|
1290 | } |
|
|
1291 | |
|
|
1292 | }); |
|
|
1293 | }); |
|
|
1294 | |
|
|
1295 | }); |
|
|
1296 | |
|
|
1297 | }); |
|
|
1298 | |
|
|
1299 | Most of the rest of the code is much simpler and just deals with forwarding user commands: |
|
|
1300 | |
|
|
1301 | } elsif ($key == $Gtk2::Gdk::Keysyms{Right}) { $mpv->cmd ("osd-msg-bar" => seek => "+10"); |
|
|
1302 | } elsif ($key == $Gtk2::Gdk::Keysyms{Left} ) { $mpv->cmd ("osd-msg-bar" => seek => "-10"); |
|
|
1303 | } elsif ($key == $Gtk2::Gdk::Keysyms{Up} ) { $mpv->cmd ("osd-msg-bar" => seek => "+60"); |
|
|
1304 | } elsif ($key == $Gtk2::Gdk::Keysyms{Down} ) { $mpv->cmd ("osd-msg-bar" => seek => "-60"); |
|
|
1305 | } elsif ($key == $Gtk2::Gdk::Keysyms{a}) ) { $mpv->cmd ("osd-msg-msg" => cycle => "audio"); |
|
|
1306 | } elsif ($key == $Gtk2::Gdk::Keysyms{j} ) { $mpv->cmd ("osd-msg-msg" => cycle => "sub"); |
|
|
1307 | } elsif ($key == $Gtk2::Gdk::Keysyms{o} ) { $mpv->cmd ("no-osd" => "cycle-values", "osd-level", "2", "3", "0", "2"); |
|
|
1308 | } elsif ($key == $Gtk2::Gdk::Keysyms{p} ) { $mpv->cmd ("no-osd" => cycle => "pause"); |
|
|
1309 | } elsif ($key == $Gtk2::Gdk::Keysyms{9} ) { $mpv->cmd ("osd-msg-bar" => add => "ao-volume", "-2"); |
|
|
1310 | } elsif ($key == $Gtk2::Gdk::Keysyms{0} ) { $mpv->cmd ("osd-msg-bar" => add => "ao-volume", "+2"); |
|
|
1311 | |
765 | =head1 SEE ALSO |
1312 | =head1 SEE ALSO |
766 | |
1313 | |
767 | L<AnyEvent>, L<the mpv command documentation|https://mpv.io/manual/stable/#command-interface>. |
1314 | L<AnyEvent>, L<the mpv command documentation|https://mpv.io/manual/stable/#command-interface>. |
768 | |
1315 | |
769 | =head1 AUTHOR |
1316 | =head1 AUTHOR |