vlc.EventManager
- class vlc.EventManager
Bases:
_CtypeCreate an event manager with callback handler.
This class interposes the registration and handling of event notifications in order to (a) remove the need for decorating each callback functions with the decorator
@callbackmethod, (b) allow any number of positional and/or keyword arguments to the callback (in addition to theEventinstance) and (c) to preserve the Python objects such that the callback and argument objects remain alive (i.e. are not garbage collected) until after the notification has been unregistered.Note
Only a single notification can be registered for each event type in an
EventManagerinstance.- _callback_handler = None
- _callbacks
- event_attach(eventtype, callback, *args, **kwds)
Register an event notification.
- Parameters:
eventtype – the desired event type to be notified about.
callback – the function to call when the event occurs.
args – optional positional arguments for the callback.
kwds – optional keyword arguments for the callback.
- Returns:
0 on success, ENOMEM on error.
Note
The callback function must have at least one argument, an
Eventinstance. Any other, optional positional and keyword arguments are in addition to the first one.Warning
LibVLC is not reentrant, i.e. you cannot call libvlc functions from an event handler. They must be called from the main application thread.
- event_detach(eventtype)
Unregister an event notification.
- Parameters:
eventtype – the event type notification to be removed.