mpv-player / mpv-examples

📚
235 stars 77 forks source link

Example libmpv c++ api embedding in wid #41

Closed time-killer-games closed 3 years ago

time-killer-games commented 3 years ago

On macOS, you can either use a global CGWindowID, or an NSWindow casted to an uintptr_t. In either case, you will need to wrap the resulting integer in a string with std::to_string or however you prefer. If an NSWindow was intented to be passed but the integer is equal to an existing CGWindowID that belongs to the app, prefer the CGWindowID in the case of such conflict. Thus, it is probably better to pass the CGWindowID via [NSWindow windowNumber] if you're paranoid about obscure results.

If the specified CGWindowID does not belong to the current app, the passed value will be treated as an NSWindow, make sure you only pass a CGWindowID that belongs to the current application process. Supports Windows, macOS, Linux, and FreeBSD out of the box. OpenBSD, NetBSD, DragonflyBSD, other *BSD's, and (I think?) Solaris/OpenSolaris might also be viable with just a matter of adding more platform macro checks to the X11/Wayland related code, which I'm happy to add on request.

No Android/iOS support; don't develop for mobile. Others can add that in if they want, and if they do they can be added to the copyright header. I am using unsigned long long instead of uintptr_t, if that is a problem or a deal breaker then let me know and I'll change it. Splash functions are synchronous and hide the cursor, you have the option to loop the video as well as close it with either the escape key or the left/right mouse button. The other video functions are asynchronous, use multi-threading, and more options.

Code is based on: https://github.com/time-killer-games/libvidplayer