Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch between video (mpv) and image (mvi) mode on the fly | with proposed solution #1

Closed
jgreco opened this issue Oct 4, 2018 · 2 comments

Comments

@jgreco
Copy link

jgreco commented Oct 4, 2018

Problem

I should be able to load a mixed content playlist and have zoom/pan functionality when viewing images but not when viewing video: mpv image.png video.mp4

The 'obvious' way of implementing this doesn't work:

[extension.jpg]
input-conf=~~/input-image.conf

I opened an issue with mpv about this a while ago but haven't heard anything, so I went looking for a work-around.

Work Around

Using add_hook("on_load"...) I can run a function that checks the "stream-open-filename" property to see if it's file extension is an image extension or not. Then I can either add or remove key bindings for image-viewer functions on the fly. When switching between files in the playlist, mpv will switch between video and image mode seamlessly.

Here is my proof of concept for this: jgreco@f6234b2

Test (with nothing special in mpv.conf) using something to the effect of: mpv image.png video.mp4

(This proof of concept only creates/removes bindings for drag_to_pan_handler and cursor_centric_zoom_handler (because those are the ones I personally use) but I think it should work in general. Also my proof of concept has keybindings hardcoded, it doesn't read them from any input.conf. I'm not sure if there is a way around this.)

@occivink
Copy link
Owner

occivink commented Nov 6, 2018

I just noticed that there is a concept of "input sections" in mpv. Bindings defined in input.conf can be added to a "section" and sections can be enabled/disabled at runtime. I think that would be a satisfying solution

@occivink
Copy link
Owner

occivink commented Nov 9, 2018

Ok I'm happy with this solution, it should be somewhat reliable. If you try it out, let me know if you find issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants