Skip to content

Kagami/mpv.d.ts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mpv.d.ts

TypeScript definitions for mpv JavaScript API.

Install

npm i -D mpv.d.ts

Usage

Example tsconfig.json:

{
  "compilerOptions": {
    "lib": ["ES5"],
    "target": "ES5",
    "module": "ESNext",
    "moduleResolution": "node"
  }
}

Note the lib and target options, those are correspond to MuJS runtime capabilities (mpv's scripting backend).

You can also import auxiliary types which are not part of the official API but provided for convenience:

import type { MP } from "mpv.d.ts";

const encoders = mp.get_property_native("encoder-list") as MP.Prop.Encoder[];
mp.msg.info(encoders.length);

mp.command_native_async(
  {
    name: "subprocess",
    args: ["echo", "test"],
    playback_only: false,
    capture_stdout: true,
  } satisfies MP.Cmd.SubprocessArgs,
  (success, res: MP.Cmd.SubprocessResult, error) => {
    mp.msg.info(res.stdout);
  }
);

About

TypeScript definitions for mpv JavaScript API

Resources

License

Stars

Watchers

Forks

Packages

No packages published