separate libmpv-internal guts into separate class
This commit is contained in:
parent
11ec85f694
commit
ea3f5ac1e9
@ -534,6 +534,8 @@ elseif(ENABLE_MEDIAPLAYER_LIBMPV)
|
|||||||
list(APPEND SOURCES
|
list(APPEND SOURCES
|
||||||
gui/mediaplayer/libmpv/libmpvbackend.cpp
|
gui/mediaplayer/libmpv/libmpvbackend.cpp
|
||||||
gui/mediaplayer/libmpv/libmpvbackend.h
|
gui/mediaplayer/libmpv/libmpvbackend.h
|
||||||
|
gui/mediaplayer/libmpv/libmpvwidget.cpp
|
||||||
|
gui/mediaplayer/libmpv/libmpvwidget.h
|
||||||
gui/mediaplayer/libmpv/qthelper.h
|
gui/mediaplayer/libmpv/qthelper.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "3rd-party/boolinq/boolinq.h"
|
#include "3rd-party/boolinq/boolinq.h"
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
|
#include "gui/mediaplayer/libmpv/libmpvwidget.h"
|
||||||
#include "gui/mediaplayer/libmpv/qthelper.h"
|
#include "gui/mediaplayer/libmpv/qthelper.h"
|
||||||
#include "miscellaneous/settings.h"
|
#include "miscellaneous/settings.h"
|
||||||
#include "miscellaneous/textfactory.h"
|
#include "miscellaneous/textfactory.h"
|
||||||
@ -43,37 +44,21 @@ static void wakeup(void* ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LibMpvBackend::LibMpvBackend(Application* app, QWidget* parent)
|
LibMpvBackend::LibMpvBackend(Application* app, QWidget* parent)
|
||||||
: PlayerBackend(app, parent), m_mpvContainer(new QWidget(this)), m_mpvHandle(nullptr) {
|
: PlayerBackend(app, parent), m_mpvContainer(nullptr), m_mpvHandle(nullptr) {
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
m_mpvHandle = mpv_create();
|
m_mpvHandle = mpv_create();
|
||||||
|
m_mpvContainer = new LibMpvWidget(m_mpvHandle, this);
|
||||||
|
|
||||||
if (m_mpvHandle == nullptr) {
|
if (m_mpvHandle == nullptr) {
|
||||||
qFatal("cannot create mpv instance");
|
qFatal("cannot create mpv instance");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a video child window. Force Qt to create a native window, and
|
|
||||||
// pass the window ID to the mpv wid option. Works on: X11, win32, Cocoa.
|
|
||||||
m_mpvContainer->setAttribute(Qt::WidgetAttribute::WA_DontCreateNativeAncestors);
|
|
||||||
m_mpvContainer->setAttribute(Qt::WidgetAttribute::WA_NativeWindow);
|
|
||||||
|
|
||||||
m_mpvContainer->setMouseTracking(true);
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
layout()->addWidget(m_mpvContainer);
|
layout()->addWidget(m_mpvContainer);
|
||||||
|
|
||||||
auto raw_wid = m_mpvContainer->winId();
|
m_mpvContainer->bind();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
// Truncate to 32-bit, as all Windows handles are. This also ensures
|
|
||||||
// it doesn't go negative.
|
|
||||||
int64_t wid = static_cast<uint32_t>(raw_wid);
|
|
||||||
#else
|
|
||||||
int64_t wid = raw_wid;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mpv_set_option(m_mpvHandle, "wid", MPV_FORMAT_INT64, &wid);
|
|
||||||
|
|
||||||
mpv_set_option_string(m_mpvHandle, "msg-level", "all=v");
|
mpv_set_option_string(m_mpvHandle, "msg-level", "all=v");
|
||||||
mpv_set_option_string(m_mpvHandle, "config", "yes");
|
mpv_set_option_string(m_mpvHandle, "config", "yes");
|
||||||
@ -91,16 +76,6 @@ LibMpvBackend::LibMpvBackend(Application* app, QWidget* parent)
|
|||||||
mpv_set_option_string(m_mpvHandle, "terminal", "yes");
|
mpv_set_option_string(m_mpvHandle, "terminal", "yes");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
|
||||||
// NOTE: Just random options for testing here.
|
|
||||||
//
|
|
||||||
// mpv_set_option_string(m_mpvHandle, "keep-open", "no");
|
|
||||||
// mpv_set_option_string(m_mpvHandle, "osd-italic", "yes");
|
|
||||||
// mpv_set_option_string(m_mpvHandle, "osd-color", "1.0/0.0/0.0");
|
|
||||||
// mpv_set_option_string(m_mpvHandle, "watch-later-dir", "mpv");
|
|
||||||
// mpv_set_option_string(m_mpvHandle, "input-builtin-bindings", "no");
|
|
||||||
// mpv_set_option_string(m_mpvHandle, "input-test", "yes");
|
|
||||||
|
|
||||||
if (!m_customConfigFolder.isEmpty()) {
|
if (!m_customConfigFolder.isEmpty()) {
|
||||||
QByteArray cfg_folder = QDir::toNativeSeparators(m_customConfigFolder).toLocal8Bit();
|
QByteArray cfg_folder = QDir::toNativeSeparators(m_customConfigFolder).toLocal8Bit();
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include <mpv/client.h>
|
#include <mpv/client.h>
|
||||||
|
|
||||||
|
class LibMpvWidget;
|
||||||
|
|
||||||
class LibMpvBackend : public PlayerBackend {
|
class LibMpvBackend : public PlayerBackend {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -61,7 +63,7 @@ class LibMpvBackend : public PlayerBackend {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_customConfigFolder;
|
QString m_customConfigFolder;
|
||||||
QWidget* m_mpvContainer;
|
LibMpvWidget* m_mpvContainer;
|
||||||
mpv_handle* m_mpvHandle;
|
mpv_handle* m_mpvHandle;
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
};
|
};
|
||||||
|
25
src/librssguard/gui/mediaplayer/libmpv/libmpvwidget.cpp
Normal file
25
src/librssguard/gui/mediaplayer/libmpv/libmpvwidget.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#include "gui/mediaplayer/libmpv/libmpvwidget.h"
|
||||||
|
|
||||||
|
#include <mpv/client.h>
|
||||||
|
|
||||||
|
LibMpvWidget::LibMpvWidget(mpv_handle* mpv_handle, QWidget* parent) : QWidget(parent), m_mpvHandle(mpv_handle) {
|
||||||
|
setAttribute(Qt::WidgetAttribute::WA_DontCreateNativeAncestors);
|
||||||
|
setAttribute(Qt::WidgetAttribute::WA_NativeWindow);
|
||||||
|
setMouseTracking(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LibMpvWidget::bind() {
|
||||||
|
auto raw_wid = winId();
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
// Truncate to 32-bit, as all Windows handles are. This also ensures
|
||||||
|
// it doesn't go negative.
|
||||||
|
int64_t wid = static_cast<uint32_t>(raw_wid);
|
||||||
|
#else
|
||||||
|
int64_t wid = raw_wid;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
mpv_set_option(m_mpvHandle, "wid", MPV_FORMAT_INT64, &wid);
|
||||||
|
}
|
24
src/librssguard/gui/mediaplayer/libmpv/libmpvwidget.h
Normal file
24
src/librssguard/gui/mediaplayer/libmpv/libmpvwidget.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
||||||
|
|
||||||
|
#ifndef LIBMPVWIDGET_H
|
||||||
|
#define LIBMPVWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
struct mpv_handle;
|
||||||
|
|
||||||
|
class LibMpvWidget : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit LibMpvWidget(mpv_handle* mpv_handle, QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
void bind();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
mpv_handle* m_mpvHandle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIBMPVWIDGET_H
|
Loading…
x
Reference in New Issue
Block a user