🧩
Seanime Extensions
🧩
Seanime Extensions
  • Seanime
    • Getting started
    • Core APIs
    • Changelog
  • Content Providers
    • Write, test, share
    • Anime torrent provider
    • Manga provider
    • Online streaming provider
  • Plugins
    • Introduction
    • Write, test, share
    • APIs
      • Helpers
      • Store
      • Storage
      • Database
      • AniList
      • System
        • Permissions
        • OS
        • Filepath
        • Commands
        • Buffers, I/O
        • MIME
    • UI
      • Basics
      • User Interface
        • Tray
        • Toast
        • Screen
        • Command Palette
        • Action
        • DOM
      • Anime/Library
        • Anime
        • Playback
        • Continuity
        • Auto Downloader
        • Auto Scanner
        • Filler Manager
        • External Player Link
      • Downloading
        • Downloader
        • Torrent Client
      • Other
        • Manga
        • Discord
        • MPV
    • Hooks
    • Example
  • Frequently asked
    • Feature requests
Powered by GitBook
On this page
  • Permissions
  • Core Methods
  • openAndPlay
  • onEvent
  • getConnection
  • stop
  1. Plugins
  2. UI
  3. Other

MPV

Interact with the user's MPV instance.

Permissions

playback permission is required

{
  //...
  "plugin": {
    "permissions": {
      "scopes": ["playback"]
    }
  }
}

Core Methods

openAndPlay

Opens and plays a file with MPV (without tracking).

Parameters:

  • filePath: String - Path to a video file

Example:

// Play a file directly with MPV without tracking
try {

  await ctx.mpv.openAndPlay("/path/to/video.mkv")
  console.log("MPV playback started")
  
} catch (error) {
  console.error("MPV playback error:", error)
}

onEvent

Issue

Do not use for Seanime versions <= 2.8.4

Registers a listener for MPV player events (fires frequently).

Parameters:

  • callback: Function(event, closed) - Callback function for events

Example:

// Monitor MPV events (use carefully - fires multiple times per second)
const unsubscribe = ctx.mpv.onEvent((event, closed) => {
  if (closed) {
    console.log("MPV connection closed")
    return
  }
  
  console.log("MPV loaded file:", event.data)
})

// Unsubscribe anytime
unsubscribe()

getConnection

Returns the underlying connection object to the MPV instance.

Returns: MpvConnection | undefined - The MPV connection if available

const conn = ctx.mpv.getConnection()

// Check the connection first
if (conn && !conn.isClosed()) {
    // shortcut to call("set_property", property, value)
    conn.set("time-pos", 90)
    
    // shortcut call("get_property", property)
    conn.get("time-pos")
    
    // This works but you should use ctx.mpv.close() instead
    conn.close()
}

stop

Stops the MPV player.

Example:

// Stop playback
try {
  ctx.mpv.stop()
} catch (e) {
  console.log("Failed to stop player", e)
}
PreviousDiscordNextHooks

Last updated 18 days ago