The Event module allows listening to mpv and IINA events.
Event names should be prefixed with either iina. or mpv. to specify the source.
This module mainly provides two methods, on and off.
The on method is used to register a callback function to an event,
which will return a unique string ID for the callback.
This ID can be used to remove the callback using the off method.
The callback function may be called with associated data,
such as the new file path for the iina.file-loaded event.
However, most events do not provide any data, and the callback function should get
necessary information from the mpv or the core module.
All mpv events can be used here by simply adding mpv. before the event name,
e.g. mpv.end-file.
Please refer to mpv's documentation for a list of mpv events.
When listenting to mpv property changes, add the .changed suffix to the property name,
e.g. mpv.volume.changed.
The IINA events are listed below.
Example
// show the file's path when playing a new file consteventID = event.on("iina.file-loaded", () => { core.osd(`Playing ${core.status.url}`); })
// remove the listener event.off("iina.file-loaded", eventID);
// using the mpv API: show the current volume when it changes event.on("mpv.volume.changed", () => { core.osd(`Volume: ${mpv.getNumber("volume")}`); });
Get notified when the width and/or height of the video has changed,
and the player window has been resized accordingly.
Typically, this is due to a new file being played, a crop filter is applied, or a video track change.
You may respond to video aspect ratio changes here.
Get notified when the player window becomes or stops being the main window.
This essentially means that the player window is or is not the frontmost window
that accepts keyboard and mouse input.
The
Event
module allows listening to mpv and IINA events. Event names should be prefixed with eitheriina.
ormpv.
to specify the source. This module mainly provides two methods,on
andoff
. Theon
method is used to register a callback function to an event, which will return a unique string ID for the callback. This ID can be used to remove the callback using theoff
method.The callback function may be called with associated data, such as the new file path for the
iina.file-loaded
event. However, most events do not provide any data, and the callback function should get necessary information from the mpv or the core module.All mpv events can be used here by simply adding
mpv.
before the event name, e.g.mpv.end-file
. Please refer to mpv's documentation for a list of mpv events. When listenting to mpv property changes, add the.changed
suffix to the property name, e.g.mpv.volume.changed
.The IINA events are listed below.
Example
Seealso
mpv's list of events.
Available In Entry
Main entry only