AnyEvent-MPV

 view release on metacpan or  search on metacpan

MPV.pm  view on Meta::CPAN

      my ($mpv, $event, $data) = @_;

      print "end-file<$data->{reason}>\n";
      $quit->send;
   });

   $mpv->cmd (loadfile => $mpv->escape_binary ($videofile));

   $quit->recv;

This example uses a global condvar C<$quit> to wait for the file to finish
playing. Also, most of the logic is now implement in event handlers.

The two events handlers we register are C<start-file>, which is emitted by
F<mpv> once it has loaded a new file, and C<end-file>, which signals the
end of a file (underscores are internally replaced by minus signs, so you
cna speicfy event names with either).

In the C<start-file> event, we again set the C<pause> property to C<no>
so the movie starts playing. For the C<end-file> event, we tell the main
program to quit by invoking C<$quit>.

MPV.pm  view on Meta::CPAN

position, if it is not at the start of the file (it would probaby be more
efficient to set the starting position before loading the file, though,
but this is good enough).

Then it plays with the display fps, to set it to something harmonious
w.r.t. the video framerate.

If the file does not have a video part, it assumes it is an audio file and
sets a visualizer.

Also, a number of properties are not global, but per-file. At the moment,
this is C<audio-delay>, and the current audio/subtitle track, which it
sets, and also creates an observer. Again, this doesn'T use the observe
functionality of this module, but handles it itself, assigning obsevrer
ids 100+ to temporary/per-file observers.

Lastly, it sets some global (or per-youtube-uploader) parameters, such as
speed, and unpauses. Property changes are handled like other input events:

      } elsif ($INPUT eq "mpv/property-change") {
         my $prop = $INPUT_DATA->{name};

         if ($prop eq "chapter-metadata") {
            if ($INPUT_DATA->{data}{TITLE} =~ /^\[SponsorBlock\]: (.*)/) {
               my $section = $1;
               my $skip;

README  view on Meta::CPAN

          my ($mpv, $event, $data) = @_;

          print "end-file<$data->{reason}>\n";
          $quit->send;
       });

       $mpv->cmd (loadfile => $mpv->escape_binary ($videofile));

       $quit->recv;

    This example uses a global condvar $quit to wait for the file to finish
    playing. Also, most of the logic is now implement in event handlers.

    The two events handlers we register are "start-file", which is emitted
    by mpv once it has loaded a new file, and "end-file", which signals the
    end of a file (underscores are internally replaced by minus signs, so
    you cna speicfy event names with either).

    In the "start-file" event, we again set the "pause" property to "no" so
    the movie starts playing. For the "end-file" event, we tell the main
    program to quit by invoking $quit.

README  view on Meta::CPAN

    position, if it is not at the start of the file (it would probaby be
    more efficient to set the starting position before loading the file,
    though, but this is good enough).

    Then it plays with the display fps, to set it to something harmonious
    w.r.t. the video framerate.

    If the file does not have a video part, it assumes it is an audio file
    and sets a visualizer.

    Also, a number of properties are not global, but per-file. At the
    moment, this is "audio-delay", and the current audio/subtitle track,
    which it sets, and also creates an observer. Again, this doesn'T use the
    observe functionality of this module, but handles it itself, assigning
    obsevrer ids 100+ to temporary/per-file observers.

    Lastly, it sets some global (or per-youtube-uploader) parameters, such
    as speed, and unpauses. Property changes are handled like other input
    events:

          } elsif ($INPUT eq "mpv/property-change") {
             my $prop = $INPUT_DATA->{name};

             if ($prop eq "chapter-metadata") {
                if ($INPUT_DATA->{data}{TITLE} =~ /^\[SponsorBlock\]: (.*)/) {
                   my $section = $1;
                   my $skip;



( run in 0.597 second using v1.01-cache-2.11-cpan-49f99fa48dc )