rossy / mpv-install

Sets up file associations for mpv on Windows
ISC License
438 stars 48 forks source link

play all with mpv in context menu #9

Closed shinchiro closed 7 years ago

shinchiro commented 7 years ago

Is it possible to implement "play all with mpv" in context menu when selecting all playable files?

rossy commented 7 years ago

It's possible, but not for a simple batch file like this. mpv-install.bat registers simple CreateProcess verb handlers for each file type. When the shell invokes these verb handlers on a selection containing multiple files, it launches an individual copy of mpv.exe for each file with the path on the command-line. As far as I know, there's no way to get the shell to put multiple files on the command-line for a single invocation of mpv.exe.

The solution for this is to set up a IDropTarget and/or IExecuteCommand verb handler as a COM local server. When you use one of these handlers, the shell sends you the entire selection as a IShellItemArray, though creating a COM local server would require an executable (.exe or .dll.) It's out-of-scope for a simple batch file like this.

As a workaround, you can put a shortcut to mpv.exe in your Send to menu (C:\Users\ your name \AppData\Roaming\Microsoft\Windows\SendTo). For some reason, Explorer is totally fine with putting multiple files on the command line if it's for an item in the Send to menu.

shinchiro commented 7 years ago

That's seem complicated stuff..thanks for the reply though

SilverEzhik commented 6 years ago

So I made a little wrapper for mpv that enables this functionality, along with using mpv as a single instance application (the way it works on macOS), please take a look, if you're interested: https://github.com/SilverEzhik/umpvw

Though, instead of handling this via COM, I am doing a bunch of IPC with mpv and with the utility itself.