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.13 by root, Mon Mar 20 14:42:40 2023 UTC vs.
Revision 1.15 by root, Wed Mar 22 01:00:36 2023 UTC

187 187
188As a rule of thumb, all data you pass to this module to be sent to F<mpv> 188As a rule of thumb, all data you pass to this module to be sent to F<mpv>
189is expected to be in unicode. To pass something that isn't, you need to 189is expected to be in unicode. To pass something that isn't, you need to
190escape it using C<escape_binary>. 190escape it using C<escape_binary>.
191 191
192Data received from C<$mpv>, however, is I<not> decoded to unicode, as data 192Data received from F<mpv>, however, is I<not> decoded to unicode, as data
193returned by F<mpv> is not generally encoded in unicode, and the encoding 193returned by F<mpv> is not generally encoded in unicode, and the encoding
194is usually unspecified. So if you receive data and expect it to be in 194is usually unspecified. So if you receive data and expect it to be in
195unicode, you need to first decode it from UTF-8, but note that this might 195unicode, you need to first decode it from UTF-8, but note that this might
196fail. This is not a limitation of this module - F<mpv> simply does not 196fail. This is not a limitation of this module - F<mpv> simply does not
197specify nor guarantee a specific encoding, or any encoding at all, in its 197specify nor guarantee a specific encoding, or any encoding at all, in its
695You can register multiple handlers for the same event, and this method 695You can register multiple handlers for the same event, and this method
696does not interfere with the C<on_event> mechanism. That is, you can 696does not interfere with the C<on_event> mechanism. That is, you can
697completely ignore this method and handle events in a C<on_event> handler, 697completely ignore this method and handle events in a C<on_event> handler,
698or mix both approaches as you see fit. 698or mix both approaches as you see fit.
699 699
700Note that unlike commands, event handlers are registered immediately, that
701is, you can issue a command, then register an event handler and then get
702an event for this handler I<before> the command is even sent to F<mpv>. If
703this kind of race is an issue, you can issue a dummy command such as
704C<get_version> and register the handler when the reply is received.
705
700=cut 706=cut
701 707
702sub AnyEvent::MPV::Unevent::DESTROY { 708sub AnyEvent::MPV::Unevent::DESTROY {
703 my ($evtcb, $event, $evtid) = @{$_[0]}; 709 my ($evtcb, $event, $evtid) = @{$_[0]};
704 delete $evtcb->{$event}{$evtid}; 710 delete $evtcb->{$event}{$evtid};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines