Skip to main content
The Deno 2 Release Candidate is here
Learn more

mpv_ipc

mpv-player/mpv JSON IPC wrapper for Deno.

Usage

The module can be imported from https://deno.land/x/mpv_ipc/mod.ts

You will need to run your scripts with the --unstable --allow-read --allow-write flags.

Example

// replace 0.1.0 with the latest tag available
import { MpvIPC } from "https://deno.land/x/mpv_ipc@0.1.0/mod.ts";

// connect to socket
// mpv file.mkv --input-ipc-server=/tmp/mpvsocket
const client = await MpvIPC.connectSocket("/tmp/mpvsocket");

// send a command and await the response
const resp1 = client.sendCommand("screenshot");
console.log(resp1);

// subscribe to specific events
const resp2 = await client.observeProperty("volume");
console.log(resp2);

// read events
for await (const event of client) {
  console.log(event);
}