… | |
… | |
62 | $quit->recv; |
62 | $quit->recv; |
63 | |
63 | |
64 | This starts F<mpv> with the two arguments C<--> and C<$videofile>, which |
64 | This starts F<mpv> with the two arguments C<--> and C<$videofile>, which |
65 | it should load and play. It then waits two seconds by starting a timer and |
65 | it should load and play. It then waits two seconds by starting a timer and |
66 | quits. The C<trace> argument to the constructor makes F<mpv> more verbose |
66 | quits. The C<trace> argument to the constructor makes F<mpv> more verbose |
67 | and also prints the commands and responses, so you cna have an idea what |
67 | and also prints the commands and responses, so you can have an idea what |
68 | is going on. |
68 | is going on. |
|
|
69 | |
|
|
70 | In 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 | |
70 | This is not usually very useful (you could just run F<mpv> as a simple |
84 | This is not usually very useful (you could just run F<mpv> as a simple |
71 | shell command), so let us load the file at runtime: |
85 | shell 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 | |
491 | This method is called when F<mpv> sends an asynchronous event. The default |
505 | This method is called when F<mpv> sends an asynchronous event. The default |
492 | implementation will call the C<on_event> code reference specified in the |
506 | implementation will call the C<on_event> code reference specified in the |
493 | constructor, or do nothing if none was given. |
507 | constructor, or do nothing if none was given. |
494 | |
508 | |
495 | The first/implicit argument is the C<$mpv> object, the second is the event |
509 | The first/implicit argument is the C<$mpv> object, the second is the |
496 | name (same as C<< $data->{event} >>, purely for convenience), and the |
510 | event name (same as C<< $data->{event} >>, purely for convenience), and |
497 | third argument is the full event object as sent by F<mpv>. See L<List of |
511 | the third argument is the event object as sent by F<mpv> (sans C<event> |
498 | events|https://mpv.io/manual/stable/#list-of-events> in its documentation. |
512 | key). See L<List of events|https://mpv.io/manual/stable/#list-of-events> |
|
|
513 | in its documentation. |
499 | |
514 | |
500 | For subclassing, see I<SUBCLASSING>, below. |
515 | For subclassing, see I<SUBCLASSING>, below. |
501 | |
516 | |
502 | =cut |
517 | =cut |
503 | |
518 | |