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.5 by root, Sun Mar 19 23:13:25 2023 UTC vs.
Revision 1.7 by root, Sun Mar 19 23:37:46 2023 UTC

62 $quit->recv; 62 $quit->recv;
63 63
64This starts F<mpv> with the two arguments C<--> and C<$videofile>, which 64This starts F<mpv> with the two arguments C<--> and C<$videofile>, which
65it should load and play. It then waits two seconds by starting a timer and 65it should load and play. It then waits two seconds by starting a timer and
66quits. The C<trace> argument to the constructor makes F<mpv> more verbose 66quits. The C<trace> argument to the constructor makes F<mpv> more verbose
67and also prints the commands and responses, so you cna have an idea what 67and also prints the commands and responses, so you can have an idea what
68is going on. 68is going on.
69
70In my case, the above example would output something like this:
71
72 [uosc] Disabled because original osc is enabled!
73 mpv> {"event":"start-file","playlist_entry_id":1}
74 mpv> {"event":"tracks-changed"}
75 (+) Video --vid=1 (*) (h264 480x480 30.000fps)
76 mpv> {"event":"metadata-update"}
77 mpv> {"event":"file-loaded"}
78 Using hardware decoding (nvdec).
79 mpv> {"event":"video-reconfig"}
80 VO: [gpu] 480x480 cuda[nv12]
81 mpv> {"event":"video-reconfig"}
82 mpv> {"event":"playback-restart"}
69 83
70This is not usually very useful (you could just run F<mpv> as a simple 84This is not usually very useful (you could just run F<mpv> as a simple
71shell command), so let us load the file at runtime: 85shell command), so let us load the file at runtime:
72 86
73 use AnyEvent; 87 use AnyEvent;
395 if ($reply->{args}[1] eq "key") { 409 if ($reply->{args}[1] eq "key") {
396 (my $key = $reply->{args}[2]) =~ s/\\x(..)/chr hex $1/ge; 410 (my $key = $reply->{args}[2]) =~ s/\\x(..)/chr hex $1/ge;
397 $self->on_key ($key); 411 $self->on_key ($key);
398 } 412 }
399 } else { 413 } else {
400 $self->on_event ($reply->{event}, $reply); 414 $self->on_event (delete $reply->{event}, $reply);
401 } 415 }
402 } elsif (exists $reply->{request_id}) { 416 } elsif (exists $reply->{request_id}) {
403 my $cv = delete $self->{cmd_cv}{$reply->{request_id}}; 417 my $cv = delete $self->{cmd_cv}{$reply->{request_id}};
404 418
405 unless ($cv) { 419 unless ($cv) {
490 504
491This method is called when F<mpv> sends an asynchronous event. The default 505This method is called when F<mpv> sends an asynchronous event. The default
492implementation will call the C<on_event> code reference specified in the 506implementation will call the C<on_event> code reference specified in the
493constructor, or do nothing if none was given. 507constructor, or do nothing if none was given.
494 508
495The first/implicit argument is the C<$mpv> object, the second is the event 509The first/implicit argument is the C<$mpv> object, the second is the
496name (same as C<< $data->{event} >>, purely for convenience), and the 510event name (same as C<< $data->{event} >>, purely for convenience), and
497third argument is the full event object as sent by F<mpv>. See L<List of 511the third argument is the event object as sent by F<mpv> (sans C<event>
498events|https://mpv.io/manual/stable/#list-of-events> in its documentation. 512key). See L<List of events|https://mpv.io/manual/stable/#list-of-events>
513in its documentation.
499 514
500For subclassing, see I<SUBCLASSING>, below. 515For subclassing, see I<SUBCLASSING>, below.
501 516
502=cut 517=cut
503 518

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines