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