Get a property as a number.
Internally, it always reads the double format of the property,
i.e. using mpv's MPV_FORMAT_DOUBLE
, because JavaScript doesn't distinguish between integers and floats.
// get the raw byte positon in the source stream
let pos = mpv.getNumber("stream-pos");
The name of the property.
Try to get the property as a native JavaScript object.
It's useful for getting dictionaries (e.g. video-params
) and lists (e.g. vf
).
// get the current video's parameters
let params = mpv.getNative("video-params");
// => { "stereo-in": "mono", "h": 1080, "w": 1920, "chroma-location": "mpeg2/4/h264", ... }
The name of the property.
Adds a mpv hook.
// the user opened an unrecognized web URL;
// run an external handler (e.g. yt-dlp) to get the actual video URL
mpv.addHook("on_load", 50, async (next) => {
// get the current URL
const url = mpv.getString("stream-open-filename");
// run the external parser
const actualURL = await runCustomHandler(url);
// set the actual URL
mpv.set("stream-open-filename", actualURL);
// continue loading the video; MUST be called if the callback is async
next();
});
mpv's hook API.
The name of the hook, such as on_load
or on_load_fail
.
The priority of the hook, should be an integer. Higher priority hooks are executed first.
The callback function to run when the hook is triggered.
If it is an async
function, the next
function must be called manually when the hook is finished.
If it is a normal function, the next
function should be ignored.
The hook callback is considered finished when the function returns.
Optional
next: (() => void)The function to call when the hook is finished, if the callback is async.
The function to call when the hook is finished, if the callback is async.
Generated using TypeDoc
The
MPV
module provides direct access to mpv's API, including properties, commands, and hooks.Remarks
Setting a window-related property in mpv, such as
fullscreen
, may also work in IINA. However, it is recommended to use IINA's own API when possible.Seealso
Please make sure to check out mpv's documentation before using this module.
For MPV events, use the event module.
Available In Entry
Main entry only