Play with MPV (Enhanced)

Combines a floating button, thumbnail clicks, and a Shift+Click fallback context menu to play videos in MPV.

作者
gabreek
日安装量
0
总安装量
10
评分
0 0 0
版本
2025.07.18.10
创建于
2025-07-09
更新于
2025-07-18
大小
17.7 KB
许可证
MIT
适用于
所有网站

Play with MPV (Enhanced)

This is a powerful UserScript that integrates website videos with the MPV media player. It combines the best features of two original scripts and adds new functionalities for a seamless experience, allowing you to play web videos in your native player with customized settings.

Prerequisites & Installation

For this UserScript to work, you need three key components installed on your system.

Note: This userscript is not compatible with Greasemonkey v4.0+. Please use a manager like Violentmonkey or Tampermonkey.

1. Dependencies

mpv-handler mpv yt-dlp

2. UserScript

Install the "Play with MPV (Enhanced)" UserScript in Violentmonkey or Tampermonkey.

Core Features

  • Floating "Play" Button: A convenient button appears on supported video pages to instantly open the current video in MPV.
  • Direct Thumbnail Clicking: Click directly on video thumbnails on supported sites (like YouTube) to open them in MPV, bypassing the site's player.
  • Universal Context Menu: On any website not explicitly supported, you can Shift + Right-Click any link to open it with MPV.
  • Centralized Settings Panel: A single, easy-to-use panel to configure your MPV preferences (quality, profile, codec, etc.) for all playback methods.
  • Automatic Video Pausing: Automatically pauses the video in your browser when it's opened in MPV.
  • Enhanced Queueing (with mpv-handler mod): When used with the mpv-handler (queue mod), the userscript leverages the handler's ability to:
    • Automatically enqueue videos to an already running MPV instance.
    • Launch a new MPV instance if none is running.

Origin & Evolution

This script is a synergistic merger of two excellent original scripts, enhancing their features and creating a unified, more powerful tool.

Original Scripts

  1. "Play with MPV" by Akatsuki Rui

    • Functionality: Provided a floating "Play" button on video pages and a robust settings panel (GM_config) to customize MPV launch options. This formed the foundation for our script's configuration and on-page button.
  2. "Click on video thumbnail to play in MPV" by nSinister

    • Functionality: Introduced the intuitive feature of clicking directly on video thumbnails to launch them in MPV. It had hardcoded settings.

What's New in This "Enhanced" Version?

This version isn't just a simple combination; it's a complete refactor that improves upon the originals:

  • Unified Functionality: The thumbnail-clicking feature now respects the settings you choose in the configuration panel.
  • Persistent Settings Button: The settings icon is now accessible on all pages of the supported sites.
  • Universal Fallback Context Menu: Use Shift + Right-Click on a link on any site to get a "Play with MPV" option.
  • Smarter Page Detection: Uses MutationObserver to reliably detect new content.

How to Use

Basic Usage

1. The Floating Button

  • On a page with a video (e.g., a YouTube watch page), the MPV play icon will appear in the bottom-left corner.
  • Clicking it will immediately open the current page's video in MPV.

2. Clicking Thumbnails

  • On supported sites like YouTube, Vimeo, etc., simply click on any video thumbnail.
  • Instead of navigating to the video page, the script will intercept the click and open the video directly in MPV.

3. The Fallback Context Menu

  • This works on any site not listed in the main configuration (e.g., news sites, educational platforms, etc.).
  • Find a link to a video.
  • Hold down the Shift key and right-click the link.
  • A custom context menu will appear with the option "Play with MPV". Click it.
  • A normal right-click (without Shift) will show the browser's default context menu.

Advanced Configuration (Userscript Settings)

You can access the settings panel to customize the script's behavior.

  • Access: On any of the supported sites (YouTube, Twitch, etc.), hover your mouse over the bottom-left corner of the screen. A settings gear icon will appear. Click it.

Here are the available options:

  • Try to Pass Cookies: (yes/no) - Attempts to pass cookies to MPV, useful for playing age-restricted or private videos.
  • MPV Profile: (text) - Specify an MPV profile to use (e.g., low-latency, default).
  • Video Quality: (select) - Choose your preferred video quality (e.g., 1080p, 720p).
  • Video Codec: (select) - Select a preferred video codec (e.g., av01, vp9).
  • Run With Console: (yes/no) - Determines if mpv-handler runs with a console window (for debugging).
  • Enqueue Mode: (on/off/default)
    • on: Forces the video to be enqueued to an existing mpv instance. If no instance is running, it will fail.
    • off: Forces a new mpv instance to be opened, even if one is already running.
    • default (recommended): The mpv-handler (queue mod) will automatically detect if an mpv instance is running and enqueue if possible, otherwise it will open a new instance. This is the default behavior of the mpv-handler mod.

Compatibility:

This userscript works with both the original mpv-handler and the mpv-handler (queue mod).

  • When used with the original mpv-handler, the userscript provides basic video playback functionality.
  • To utilize the enhanced queueing features (automatic detection and enqueue option), you must use the mpv-handler (queue mod).

Installation:

  1. Install a Userscript Manager: (e.g., Tampermonkey, Violentmonkey).
  2. Install this Userscript: Click the "Install" button on this Greasy Fork镜像 page.
  3. Install and Configure mpv-handler (queue mod): Follow the instructions in the mpv-handler (queue mod) GitHub repository to install and configure the handler, especially setting up the MPV IPC socket.

GitHub & Credits

This project stands on the shoulders of giants.

Enjoy a more seamless and powerful video playback experience!

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址