mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.04k stars 2.88k forks source link

Overlay video window on macOS Sierra (PiP) #3612

Open herrbischoff opened 8 years ago

herrbischoff commented 8 years ago

In Sierra there is a new feature of an overlay video window that's resizable and stays put on all spaces. If it is at all possible to implement this behaviour in mpv, I would very much appreciate it being added. I am aware of an already available overlay function. However, this overlaid window stays on the space it was put, not floating above different spaces.

jdek commented 8 years ago

Could you point to this function? As far as I'm aware it looks like a safari-only feature.

herrbischoff commented 8 years ago

It indeed appears to be limited to Safari and iTunes for the time being. I was hoping someone might have traversed the developer docs deeper than I have and found something to make it work with other applications.

jdek commented 8 years ago

Yes, I think it's a private API for now. Definitely something which may be possible in the future but at this point in time it doesn't seem so (without reimplementing it).

edit:

it may be https://developer.apple.com/reference/appkit/nswindowcollectionbehavior/1419246-canjoinallspaces

mightysashiman commented 7 years ago

Hi, I accidentally opened a new feature request about PiP. Here's info which may be relevant :

https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/AdoptingMultitaskingOniPad/QuickStartForPictureInPicture.html

EDIT : nope, my bad again, this is Ipad related info, not MacOS. Hope this changes soon..

Akemi commented 7 years ago

some additional info. we would also need NSWindowCollectionBehaviorFullScreenAuxiliary in combination with NSWindowCollectionBehaviorCanJoinAllSpaces.

ghost commented 7 years ago

@Akemi That's incredible. So it seems like there is no need to hack into the private PiP framework. Just setting "window can appear on all spaces" and "window can appear on top of fullscreen apps" sounds like a brilliant and pretty easy solution, if that's really all it takes.

And as you said (https://github.com/mpv-player/mpv/commit/a8347eb9ba9e09177da50592fde7f3ae7261ce59#commitcomment-20239490), it may also need some window snapping logic if you want to go the whole way towards emulating PiP, but that's nowhere near as important as just being able to see the mpv window on all spaces. That's the single remaining benefit of Apple's PiP over mpv when working. Switching between spaces and not having to manually drag the player along with us is a really great feature, hehe.

If you decide to add this feature, I would prefer it to be a triggerable Lua/Keybinding command, perhaps by setting one or two new mpv properties: "cocoa-canjoinallspaces" and "cocoa-showonfullscreenspace" (with some nicer names). Then people could trigger it by setting those properties either in mpv.conf or via Lua/keybinds. And they could opt in to "always show on all spaces, except fullscreen spaces", etc. Which would be very impressive. But that assumes that the Cocoa view properties are allowed to change during runtime. If that isn't possible, then static Cocoa view initialization properties in mpv.conf / command line arguments would do just as fine. Especially if they can be put in [profile] sections to easily launch the player in the proper mode.

Oh and any "automatic snapping/sizing" behavior (which isn't an important feature imo) should preferably be opt-in too. Just to preserve the absolute control of mpv in letting the user size and move the window anywhere they want.

Just thinking out loud. "Always show in all spaces" would open up some exciting possibilities that really takes mpv over the edge. Ever since I discovered Safari PiP on Sierra, I've been enjoying videos so much more. Before this, I barely ever watched any videos at all. It's rare that I have time to just sit down and focus on a video in fullscreen. But PiP mode finally lets people have some fun, non-intrusive entertainment while working. :)

ghost commented 7 years ago

I found some additional info:

https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/WinPanel/Articles/SettingWindowCollectionBehavior.html

Spaces Collection Behavior

There are three options that can be set for a window’s Spaces collection behavior. The default is NSWindowCollectionBehaviorDefault, which allows the window to be associated with one space at a time. The second option is NSWindowCollectionBehaviorCanJoinAllSpaces. This option causes the window to appear on all spaces, like the menu bar. The third option is NSWindowCollectionBehaviorMoveToActiveSpace. This causes the window to switch to the active space when it is made active. Only one of these options may be used at a time.

If a window is currently associated with the active space, isOnActiveSpace returns YES. Otherwise, it returns NO. Additionally, you can get an array of the window numbers of windows on one or all spaces using the method windowNumbersWithOptions: and specified your desired options. The possible options are specified by NSWindowNumberListOptions.

Exposé Collection Behavior

There are also three options that can be set for a window’s Exposé collection behavior. If a window has a window level of NSNormalWindowLevel, the default behavior is NSWindowCollectionBehaviorManaged, which causes the window to participate in both Spaces and Exposé. NSWindowCollectionBehaviorTransient causes the window to float in Spaces and be hidden in Exposé. This is the default behavior if the window level is not NSNormalWindowLevel. The final option is NSWindowCollectionBehaviorStationary, which causes the window to be unaffected by Exposé; i.e. it stays visible and does not move, like the desktop window. Only one of these options may be used at a time.

Thoughts:

  1. Try adding NSNormalWindowLevel. Currently, going to Mission Control/Expose causes mpv to be hidden from the view of open windows. Adding that flag should fix it.

  2. As for "showing a window in all spaces", you can see that there is a third option called NSWindowCollectionBehaviorMoveToActiveSpace which I think sounds more appropriate. It makes the window automatically move itself to the active space. The other mode (NSWindowCollectionBehaviorCanJoinAllSpaces) sounds like it makes the window render in all spaces simultaneously (so a dual screen setup would maybe see two windows, one on each screen?). Experimentation is needed to figure those out.

nguyenhimself commented 7 years ago

Hate to be that guy, but has there been any progress on this feature?

I was reminded of this because IINA, a macOS front-end for mpv, has added Picture-in-Picture, and well, it's kinda nice :) I still prefer the mainline mpv though.

Akemi commented 7 years ago

as far as it concerns me i didn't work on it (yet). IINA also uses a private API which isn't an option for mpv.

ghost commented 7 years ago

@nguyenhimself Wow, that IINA project is everything that BakaMPlayer (the other, older mpv frontend for Mac) is not. Sleek and beautiful as hell.

I would switch to IINA if it had 100% compatibility with ~/.config/mpv and all user scripts and custom keybindings etc. Do you know if that's the case? Or do they only use their own locked-down settings system?

Something like IINA would be great for my girlfriend who doesn't remember the keyboard shortcuts I use in mpv. And if we can use the same powerful and configurable mpv config/script system to get the best of both worlds I'd be sold on it!

Edit: Amazing... IINA created their gitignore in July of 2016 so I guess the project is half a year old. Amazing progress so far. And the repo itself was uploaded to GitHub at "2016-12-19T07:18:45Z". No wonder I didn't know it existed! It's brand new.

I kinda wish they'd put all of that energy into helping us make an alternative built-in GUI for the official mpv app instead, though. Something like "--mac-interface=iina", to run this alternative GUI instead of the standard "basic output frame" we've got. The basic frame must always exist (it's classic and I may even prefer it), but IINA looks beautiful. I guess they wanted the pride of "their own" project instead of extending the core, though. ;\

Akemi commented 7 years ago

mpv itself isn't interested in adding a proper GUI. it encouraged others to use libmpv and do such things. IINA uses all the things mpv also supports, though not everything works properly so far. one thing i know of is display-resamle+interpolation.

Akemi commented 7 years ago

@nguyenhimself if i had to guess it's probably your vo=opengl-hq line.

ghost commented 7 years ago

@Akemi Thanks for the explanation. That's actually a cool idea. Letting others make more advanced GUIs via libmpv.

@nguyenhimself I think I may prefer the classic mpv GUI too, and it's easy enough for even non-geeks to click File-Quit to exit and to just use the mouse to click the OSD seek-bar manually. But the problem is when advanced things like playlists, subtitle selection, audio track, audio delay, etc needs to be done. It really confuses everyone I know (not myself). So I'll be trying out IINA. Thanks both of you for the information! <3 I will comment out opengl-hq and try it soon. It's very cool what they've done in just half a year of development. Hopefully they find a fix for advanced OpenGL shaders.

EDIT: Alright, IINA is not ready for primetime yet. It came out publicly just 2 months ago. Amazing for 6 months of development, but I'll revisit it in another 6-12 when things have been ironed out. ;-) Sticking with the true and stable mpv core for now!

herrbischoff commented 4 years ago

It's been three years since the last comment on this issue. It appears unlikely this feature ever gets implemented and with IINA there is now a macOS "native" player with a similar functionality for those who seek it. Closing.

Akemi commented 4 years ago

since i am very much interested in this feature myself i will reopen this feature request. i am still hoping for a none private framework that 'just works' solution, though this will probably not happen.