Mpv: Feature request: single instance mode

Created on 4 Oct 2017  Â·  19Comments  Â·  Source: mpv-player/mpv

As in, pass the file(s) and\or URL(s) to an existing mpv instance instead of running another one. It'll be a lot faster than waiting for another instance of mpv to launch.

All 19 comments

Sadly, I'm not on Linux. I tried making an AutoHotkey macro, too, but mpv silently ignored any PostMessage "file drop" events (whereas notepad didn't).

Linux only, it seems?

Currently, sending loadfile to mpv's named pipe is the only way around it.

Check - https://gist.github.com/dwgill/a66769e0edef69c04d3b . This has example of how to use loadfile.

I'd love this option. I use MPV as my default player on Windows, and need to be able to set the option so that it works when opening the file from explorer as well as from the command line.

My use case is, I'll be looking through a folder of footage or renders on my edit machine. Opening each one opens up a new window, meaning I end up with dozens of videos playing back simultaneously., often hidden behind other windows.

Other players like VLC or MPC* do it, how is it so hard for MPV? Not rhetorical, I'm actually interested.

Does MPV have any command internal system that can be used?

JSON IPC

This is so hard to implement?

Probably not, but I don't see anything in this feature (most programs I use which do it I try to disable it). Let me correct myself: I really hate this feature whenever something uses it. If I start a program, I want a new program, not something retarded like affecting existing instances.

Also even if it were implemented, it'd probably cause a bunch of problems we'd have to care about.

The way I could see this feature being implemented, FWIW, is basically as an extension of input-ipc-server. Basically, if the filename specified by input-ipc-server already exists, mpv would first connect to it and send a quit message to the existing instance, before replacing it.

Perhaps something like input-ipc-conflict-action=<ignore|replace|error> which translates to something like “do nothing, leave both instances running”, “send a quit message to the existing instance” and “error out and refuse to run if the socket already exists” respectively.

That way the logic for deciding how and when to behave in “single instance mode” is pretty much left to the user, and there are also clear semantics for how this is implemented on each platform, and you could even have multiple coexisting “single instance groups”. (For example, your file manager might be configured to start mpv with the socket pointing at /run/user/$UID/mpv.filemanager.socket, so that clicking on multiple files from your file manager replaces the same instance every time - but doesn't affect mpv as run from the command line)

I don't think quitting the other instance would cut it - it would destroy and possibly recreate the window, and reset state like the window position or audio volume. The other modes seem rather useless compared to just using a dedicated script like umpv.

Hi, I gave implementing single instance mode for Windows a shot: https://github.com/SilverEzhik/umpvw

It handles things macOS-style - opening a file will replace what you have running`. It also handles opening multiple files as a playlist.

I don't think quitting the other instance would cut it - it would destroy and possibly recreate the window, and reset state like the window position or audio volume. The other modes seem rather useless compared to just using a dedicated script like umpv.

Most of the time I only need one mpv instance to run and i usually want the newly opened file to replace what's already running. umpv seems to only append the file to playlist and that doesnt cut it for me. I dont really use application volume, mostly set to max and the window position and size is explicitly defined in my mpv config( i either watch a video as a pop up or in fullscreen). I use a custom script to kill the currently running mpv instance and relaunch with the new video. For me the annoying thing is the second or two it takes to kill and relaunch mpv.

Smplayer seems to have this feature and its based on mpv. I would love to see this implemented in mpv

@aiamkobby commented on null:

[...] umpv seems to only append the file to playlist and that doesnt cut it for me.

Change append to replace on line 81.

You need to make triple-flips for just a basic functionality. This holds for practically anything in mpv.
It already feels I have some darn constructor for thumbnail-preview, volume-control on mouse scroll, On-top only when playing, Hide/Show borders and now single instance?

Let alone for not so basic features

@AjvarXX If you think thats a "triple-flip", i suppose you are Not the Type of User the Player is Designed for.
Just Use Other frontends where everything is configured for you already :)

you are Not the Type of User the Player is Designed for...

Yeah-yeah, I heard same lines from devs and I won't argue saying that you don't hear those if product is indeed ideal, open-source or not. I will let it for their own judging.

  1. Google the question.
  2. Same as for Linux, there are only few results and lucky you if at least one Resolved.
  3. Follow long instructions on downloading/editing configs for something which intuitively deserves 1-click if not Out-of-the-box solution.

Another issue with using umpvw is that it doesn't switch to the mpv window, so if it's covered with other windows you have to manually switch to it.

This (simple) solution appears to work well. Note: Linux.

MPV SINGLE INSTANCE MODE

  • script: /mnt/Vancouver/programming/scripts/mpv.sh
  • desktop entry: /home/victoria/.local/share/applications/mpv-single-instance.desktop
  • associate (Krusader file manager) FLV, MKV, MP4, MPG, MPEG, AVI, WEBM, ... files with that single-instance program
  • also added to XFCE Whiskers Menu

  • mpv.sh (/mnt/Vancouver/programming/scripts/mpv.sh):
#!/bin/bash
# vim: set filetype=sh :
# vim: syntax=sh
export LANG=C.UTF-8

pid=$(pidof "mpv")

if [[ "$pid" ]]; then
    kill "$pid"
fi

mpv --player-operation-mode=pseudo-gui "$1"

mpv-single-instance.desktop:

```
[Desktop Entry]
Version=1.0
Type=Application
Name=MPV (single instance)
Comment=Run only one instance of mpv

Exec=mpv_single %f

Exec=/mnt/Vancouver/programming/scripts/mpv.sh %f
Icon=mpv
MimeType=application/ogg;application/x-ogg;application/sdp;application/smil;application/x-smil;application/streamingmedia;application/x-streamingmedia;application/vnd.rn-realmedia;application/vnd.rn-realmedia-vbr;audio/aac;audio/x-aac;audio/m4a;audio/x-m4a;audio/mp1;audio/x-mp1;audio/mp2;audio/x-mp2;audio/mp3;audio/x-mp3;audio/mpeg;audio/x-mpeg;audio/mpegurl;audio/x-mpegurl;audio/mpg;audio/x-mpg;audio/rn-mpeg;audio/ogg;audio/scpls;audio/x-scpls;audio/vnd.rn-realaudio;audio/wav;audio/x-pn-windows-pcm;audio/x-realaudio;audio/x-pn-realaudio;audio/x-ms-wma;audio/x-pls;audio/x-wav;video/mpeg;video/x-mpeg;video/x-mpeg2;video/mp4;video/msvideo;video/x-msvideo;video/ogg;video/quicktime;video/vnd.rn-realvideo;video/x-ms-afs;video/x-ms-asf;video/x-ms-wmv;video/x-ms-wmx;video/x-ms-wvxvideo;video/x-avi;video/x-fli;video/x-flv;video/x-theora;video/x-matroska;video/webm;audio/x-flac;audio/x-vorbis+ogg;video/x-ogm+ogg;audio/x-shorten;audio/x-ape;audio/x-wavpack;audio/x-tta;audio/AMR;audio/ac3;video/mp2t;audio/flac;audio/mp4;
111

duplicate of #3811

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lightonflux picture lightonflux  Â·  4Comments

xanadupark picture xanadupark  Â·  3Comments

sant527 picture sant527  Â·  4Comments

SPDurkee picture SPDurkee  Â·  3Comments

szg0000 picture szg0000  Â·  3Comments