1
0
Fork 0

Minor changes.

This commit is contained in:
Kitteh 2018-10-21 13:00:25 +01:00
parent de9bd47082
commit 08e9fcf55a
4 changed files with 11 additions and 28 deletions

View file

@ -19,7 +19,7 @@
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1); setenv("QT_QUICK_CONTROLS_STYLE","Desktop",1);
QApplication app(argc, argv); QApplication app(argc, argv);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
qmlRegisterType<MpvObject>("player", 1, 0, "MpvObject"); qmlRegisterType<MpvObject>("player", 1, 0, "MpvObject");

View file

@ -140,7 +140,6 @@ public:
// See render_gl.h on what OpenGL environment mpv expects, and // See render_gl.h on what OpenGL environment mpv expects, and
// other API details. // other API details.
mpv_render_context_render(obj->mpv_gl, params); mpv_render_context_render(obj->mpv_gl, params);
obj->window()->resetOpenGLState(); obj->window()->resetOpenGLState();
#else #else
QOpenGLFramebufferObject *fbo = framebufferObject(); QOpenGLFramebufferObject *fbo = framebufferObject();
@ -169,24 +168,22 @@ MpvObject::MpvObject(QQuickItem * parent)
throw std::runtime_error("could not create mpv context"); throw std::runtime_error("could not create mpv context");
mpv_set_option_string(mpv, "terminal", "yes"); mpv_set_option_string(mpv, "terminal", "yes");
//mpv_set_option_string(mpv, "msg-level", "all=v"); mpv_set_option_string(mpv, "msg-level", "all=v");
if (mpv_initialize(mpv) < 0) if (mpv_initialize(mpv) < 0)
throw std::runtime_error("could not initialize mpv context"); throw std::runtime_error("could not initialize mpv context");
#ifndef USE_RENDER #ifndef USE_RENDER
mpv::qt::set_option_variant(mpv, "vo", "opengl-cb"); mpv::qt::set_option_variant(mpv, "vo", "opengl-cb");
#else
mpv::qt::set_option_variant(mpv, "vo", "libmpv");
#endif #endif
// Enable default bindings, because we're lazy. Normally, a player using // Enable default bindings, because we're lazy. Normally, a player using
// mpv as backend would implement its own key bindings. // mpv as backend would implement its own key bindings.
mpv_set_option_string(mpv, "input-default-bindings", "yes"); // mpv_set_option_string(mpv, "input-default-bindings", "yes");
// Enable keyboard input on the X11 window. For the messy details, see // Enable keyboard input on the X11 window. For the messy details, see
// --input-vo-keyboard on the manpage. // --input-vo-keyboard on the manpage.
mpv_set_option_string(mpv, "input-vo-keyboard", "yes"); // mpv_set_option_string(mpv, "input-vo-keyboard", "yes");
// Fix? // Fix?
mpv::qt::set_option_variant(mpv, "ytdl", "yes"); mpv::qt::set_option_variant(mpv, "ytdl", "yes");
@ -194,8 +191,6 @@ MpvObject::MpvObject(QQuickItem * parent)
mpv_set_option_string(mpv, "input-default-bindings", "yes"); mpv_set_option_string(mpv, "input-default-bindings", "yes");
mpv_set_option_string(mpv, "input-vo-keyboard", "yes"); mpv_set_option_string(mpv, "input-vo-keyboard", "yes");
mpv::qt::set_option_variant(mpv, "idle", "once");
mpv::qt::set_option_variant(mpv, "hwdec", "off"); mpv::qt::set_option_variant(mpv, "hwdec", "off");
mpv::qt::set_option_variant(mpv, "slang", "en"); mpv::qt::set_option_variant(mpv, "slang", "en");
@ -229,6 +224,8 @@ mpv_gl = (mpv_opengl_cb_context *)mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB);
mpv_opengl_cb_set_update_callback(mpv_gl, MpvObject::on_update, (void *)this); mpv_opengl_cb_set_update_callback(mpv_gl, MpvObject::on_update, (void *)this);
#endif #endif
mpv::qt::set_option_variant(mpv, "idle", "once");
connect(this, &MpvObject::onUpdate, this, &MpvObject::doUpdate, connect(this, &MpvObject::onUpdate, this, &MpvObject::doUpdate,
Qt::QueuedConnection); Qt::QueuedConnection);
} }
@ -261,19 +258,6 @@ void MpvObject::doUpdate()
} }
QVariant MpvObject::getThumbnailFile(const QString &name) const
{
QProcess process;
process.start("youtube-dl --get-thumbnail " + name);
process.waitForFinished(-1);
return process.readAllStandardOutput();
}
QVariant MpvObject::getProperty(const QString &name) const QVariant MpvObject::getProperty(const QString &name) const
{ {
return mpv::qt::get_property_variant(mpv, name); return mpv::qt::get_property_variant(mpv, name);

View file

@ -55,7 +55,6 @@ public slots:
void setProperty(const QString& name, const QVariant& value); void setProperty(const QString& name, const QVariant& value);
void setOption(const QString& name, const QVariant& value); void setOption(const QString& name, const QVariant& value);
QVariant getProperty(const QString& name) const; QVariant getProperty(const QString& name) const;
QVariant getThumbnailFile(const QString& name) const;
signals: signals:
@ -75,4 +74,4 @@ private:
#endif #endif

View file

@ -133,7 +133,6 @@ Window {
id: notoFont id: notoFont
source: "fonts/NotoSans.ttf" source: "fonts/NotoSans.ttf"
} }
Component.onCompleted: { startPlayer() }
function startPlayer() { function startPlayer() {
var args = Qt.application.arguments var args = Qt.application.arguments
@ -145,7 +144,7 @@ Window {
for (argNo = 1; argNo < len; argNo++) { for (argNo = 1; argNo < len; argNo++) {
var argument = args[argNo] var argument = args[argNo]
if (argument.indexOf("KittehPlayer") !== -1) { continue; } if (argument.indexOf("KittehPlayer") !== -1) { continue; }
/* if (argument.startsWith("--")) { if (argument.startsWith("--")) {
argument = argument.substr(2) argument = argument.substr(2)
if (argument.length > 0) { if (argument.length > 0) {
var splitArg = argument.split(/=(.+)/) var splitArg = argument.split(/=(.+)/)
@ -158,9 +157,9 @@ Window {
renderer.setOption(splitArg[0], splitArg[1]) renderer.setOption(splitArg[0], splitArg[1])
} }
} }
} else { */ } else {
renderer.command(["loadfile", argument, "append-play"]) renderer.command(["loadfile", argument, "append-play"])
//} }
} }
} }
} }
@ -693,5 +692,6 @@ Window {
updateControls() updateControls()
} }
} }
Component.onCompleted: { startPlayer() }
} }
} }