Open nmoorthy524 opened 7 years ago
It's a feature. On Linux there's a script (umpv
) to get one-process behavior, but not on Windows. (Though you could attempt to write such a script for Windows.)
I need this feature,It could open many file at the same time? how could I switch on this function?
As a possible workaround, there's rossy's mpv-open-file-dialog
Lua script.
Thanks
I found 2 things, but I'm not sure how to use them. Notify me if you know. This uses a program and registry entry. zenden2k/context-menu-launcher and the other is Powershell Code
$process = "mspaint"
$ret = Get-Process -Name $process -ErrorAction SilentlyContinue
if ($ret) {
Write-Host "INFO: $process already running, skipping start of another instance of the same process"
} else {
Write-Host "VERBOSE: Starting $process now"
Invoke-Item "$process.exe"
}
@rossy @yangyzp
Another script It runs properly from powershell.
if (-Not (Get-Process "mpv" -ErrorAction SilentlyContinue | Where-Object {-not $_.HasExited }))
{
& "C:\mpv\mpv.exe"
}
With all due respect, using PowerShell to do just that is stupid damn, it's like wanting to kill flies to cannon shots. Not to mention that PowerShell is just another "permanent security hole" in the operating system.
This batch do exact the same:
@echo off
tasklist | find /i "mpv.exe"
if errorlevel 1 start "" mpv.exe %*
A more hostile variant:
@echo off
taskkill /im "mpv.exe" /f
start "" mpv.exe %*
Less hostile...:
@echo off
taskkill /im "mpv.exe"
ping 127.0.0.1 -n 2 >nul
start "" mpv.exe %*
cya
ping 127.0.0.1 -n 2 >nul
Just to avoid any possible confusion: This is just the old wait trick..
I posted this on another issue already, but this one appears to be specifically about Windows.
Anyway, 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 via IPC.
I don't understand why dev team does not implement this mechanism by creating a simple named kernel object (e.g. semaphore) at startup and check if the particular object exists at startup and if so redirect playback request to existing instance and terminate the extra instance. This is usually how it is handled instead of unnecessary 3rd party scripts. Can somebody explain?
i don't know who that "dev team" team is. though that person probably doesn't want to implement it since they doesn't see a need for it.
i don't know who that "dev team" team is. though that person probably doesn't want to implement it since they doesn't see a need for it.
Here's a need for it: You are already playing a file in the background, meanwhile you are also exploring other files, finally you decide to choose a new file to play and click on it. Now you have two instances playing different files simultaneously causing you to manually have to close the other instance, which could have been solved with the method i have talked about. This is not a obscure niche feature, it is already implemented in various software (e.g. MPC-HC, VLC etc.).
I am aware of the open source nature of the project and I know that there is not a "dev team" per se. But usually in every project there is a team of people actively working on the project, that's what I meant.
that's just the use case and no one questioned that one.
i meant a personal need, so that person is not implementing it. if the interests of that specific dev doesn't align with the interest of specific users it can't be helped. there is even less of an incentive since it is already possible with scripts etc and if one doesn't aim for a specific implementations this issue is basically 'solved'.
you either have to wait till someone implements your wanted feature or you have to do it yourself.
os:win
sry
I'm new to using mpv and I've been trying to figure out how to deal with this on Windows. I've already installed using shinchiro's build from mpv's site. Should I be using @SilverEzhik 's method to fix it. If so, how would I go about that if I already have the latest build installed?
If I should be creating a batch file, how should I be handling it(how to make it run when I want to, and how to make it stop when it shouldn't be running)? @Jj0YzL5nvJ
Should I be using @SilverEzhik 's method to fix it. If so, how would I go about that if I already have the latest build installed?
Most likely yes, just follow the instructions found at his other repo here.
Alternatively, I also made the following batch file a long time ago to test single-instance mode via the built-in Windows cmd.exe facility, so I'll just paste it below in case someone finds it useful:
@echo off
setlocal enableextensions enabledelayedexpansion
:: strip double quotes from the "%1" argument if present, just in case (it'll be added later)
set "input=%~1"
:: convert backslashes into forward slashes, so 'echo loadfile' doesn't need escaped backslashes
set "output=%input:\=/%"
set cli_args=%*
set mpv_args=!cli_args:%1=!
tasklist /FI "IMAGENAME eq mpv.exe" 2>nul | findstr /i "mpv.exe" >nul
IF %errorlevel% EQU 0 ( goto :mpvIsRunning ) ELSE (
start "" mpv.exe --input-ipc-server=mpv-socket %mpv_args% "%output%"
goto :End
)
:mpvIsRunning
echo loadfile "%output%">\\.\pipe\mpv-socket
:End
endlocal
I'm new to using mpv and I've been trying to figure out how to deal with this on Windows. I've already installed using shinchiro's build from mpv's site. Should I be using @SilverEzhik 's method to fix it. If so, how would I go about that if I already have the latest build installed?
If I should be creating a batch file, how should I be handling it(how to make it run when I want to, and how to make it stop when it shouldn't be running)? @Jj0YzL5nvJ
@shinchiro, how about an alternative installer using @garoto's script?
@shinchiro, how about an alternative installer using @garoto's script?
Please don't. This is just a silly prototype, if even that, and while it seems to work as far I was able to test it, I can only imagine it can|will fail in many specific circunstances. Also, associating this .bat
in the registry for video extensions, will make a cmd.exe
window to pop-up briefly everytime a video is launched from any GUI application, and that's not very pretty.
--started-from-file --playlist-enqueue
works for VLC.
I think there'd be a command line for mpv to solve this issue?
For anybody still dealing with this on Windows 10, I packaged mpv for the Microsoft Store with a single instance mode wrapper and file association defaults: https://www.microsoft.com/store/productId/9P3JFR0CLLL6
The source is available here: https://github.com/SilverEzhik/mpv-msix
Hi, I implemented a more versatile version of above mentioned zenden2k/context-menu-launcher.
https://github.com/ge9/ExecuteCommand-Pipe
It can pass input files to any program through standard input (in UTF-8). No change of order during interprocess communication, and no limitation on path length or number of files. I confirmed it works perfectly with mpv. (It has no function of appending files to the queue in existing mpv window)
anyone knows how to enable this UMPV feature in linux?
https://raw.githubusercontent.com/mpv-player/mpv/master/TOOLS/umpv
On Arch you can get it from /usr/share/mpv/scripts/umpv.
I am on the latest windows 64 bit build available here: https://mpv.srsfckn.biz/ (10/20 as of today). I already have mpv as the default filetype. When I have mpv already open and I click on a video to play in my file explorer, instead of playing in the already open mpv process, it creates a new one so now there's 2 mpvs playing. Is this as intended and if so, how do I make it stick to using only 1 process?