AnyEvent-MPV

 view release on metacpan or  search on metacpan

MPV.pm  view on Meta::CPAN

   $guards->{file_loaded} = $mpv->register_event (file_loaded => sub {
      delete $guards->{file_loaded};
      return if $guards != $self->{mpv_guards};

Commands do not have guards since they cnanot be cancelled, so we don't
have to do this for commands. But what prevents us form misinterpreting
an old event? Since F<mpv> (by default) handles commands synchronously,
we can queue a dummy command, whose only purpose is to tell us when all
previous commands are done. We use C<get_version> for this.

The simplified code looks like this:

   Scalar::Util::weaken $self;

   $mpv->cmd ("get_version")->cb (sub {

      $guards->{file_loaded} = $mpv->register_event (file_loaded => sub {
         delete $guards->{file_loaded};
         return if $guards != $self->{mpv_guards};

         $mpv->cmd (get_property => "video-format")->cb (sub {

README  view on Meta::CPAN

       $guards->{file_loaded} = $mpv->register_event (file_loaded => sub {
          delete $guards->{file_loaded};
          return if $guards != $self->{mpv_guards};

    Commands do not have guards since they cnanot be cancelled, so we don't
    have to do this for commands. But what prevents us form misinterpreting
    an old event? Since mpv (by default) handles commands synchronously, we
    can queue a dummy command, whose only purpose is to tell us when all
    previous commands are done. We use "get_version" for this.

    The simplified code looks like this:

       Scalar::Util::weaken $self;

       $mpv->cmd ("get_version")->cb (sub {

          $guards->{file_loaded} = $mpv->register_event (file_loaded => sub {
             delete $guards->{file_loaded};
             return if $guards != $self->{mpv_guards};

             $mpv->cmd (get_property => "video-format")->cb (sub {



( run in 0.434 second using v1.01-cache-2.11-cpan-64827b87656 )