libmpv examples in "scripting" languages? #16716
Replies: 1 comment
-
|
There's a library called python-mpv that can be used in scripting: https://github.com/jaseg/python-mpv I develop two frontend that use it: MediaHug and MpvBuddy If you just want to use Python to launch and mpv window, I do that here: https://gitlab.com/djsumdog/mpvbuddy/-/blob/master/mpvbuddy/gui/mpv.py If you want to embed mpv in a Qt6 application (as a QWidget), I do that between these two classes (only works in X11): https://gitlab.com/djsumdog/mediahug/-/blob/master/mediahug/gui/mpv/player.py https://gitlab.com/djsumdog/mediahug/-/blob/master/mediahug/gui/mpv/x11_player.py and if you need to use mpv in a QWidget in Wayland, you're going to have to use a QOpenGLWidget like here: https://gitlab.com/djsumdog/mediahug/-/blob/master/mediahug/gui/mpv/gl_player.py If you use QQuick instead of QWidgets, you can use this person's examples: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there people,
I read elsewhere that libmpv can be used to play videos, say, via python.
A simple GUI could be used too, for instance, libui-ng; or if that is not working well on windows, just something like GTK on linux.
I am mostly interested in a super-simple example here, to show the very basics, the simplest way possible to get an embedded window where mpv plays a video file, such as in a minimal GTK application (with file path + button, and upon button press, the file path in the gtk-entry is used for the path to the video file, then the video is played via mpv but within that GTK window as it is). For instance, a file called foobar.mp4, that can be played via python that makes use of a GUI. The GUI would be simple: a button to do the "play video file", and then mpv (or libmpv) plays it. Keep it simple. While I mention python, it could be any other language too. I am mostly interested in how this could be done, so I can learn and perhaps adapt this use case to ruby eventually. (Via libx11/xorg I think we can somehow use the PID/ID and that can be used via gtk; I used this a few years ago and that worked, but I used "mpv" via a system() call if I recall correctly. I think it may be nicer to use libmpv instead, but I don't know the API at all right now.)
Does anyone happen to know of an example for the above use case? E. g. to have, say, python play a mp4 file via mpv/libmpv? The idea would be that this is actually embedded in the GUI. We can of course use python already and mpv will start a new window, but I am here interested specifically how to "embed" what mpv displays in a GUI. This base could then be used to extend the GUI with more options and commandline things, a bit like smplayer (https://github.com/smplayer-dev/smplayer) does (but I would prefer that via a "scripting" language so I can have more control over it).
Beta Was this translation helpful? Give feedback.
All reactions