1
0
Fork 0

Make player stop after playback finished. Make window title same as media title.

This commit is contained in:
NamedKitten 2018-10-16 11:07:14 +01:00
parent 14c9ff1b6d
commit a4957d6219
2 changed files with 19 additions and 14 deletions

View file

@ -177,12 +177,22 @@ MpvObject::MpvObject(QQuickItem * parent)
#ifndef USE_RENDER
mpv::qt::set_option_variant(mpv, "vo", "opengl-cb");
#endif
// Enable default bindings, because we're lazy. Normally, a player using
// mpv as backend would implement its own key bindings.
mpv_set_option_string(mpv, "input-default-bindings", "yes");
// Enable keyboard input on the X11 window. For the messy details, see
// --input-vo-keyboard on the manpage.
mpv_set_option_string(mpv, "input-vo-keyboard", "yes");
// Fix?
mpv::qt::set_option_variant(mpv, "ytdl", "yes");
mpv_set_option_string(mpv, "input-default-bindings", "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");
@ -319,24 +329,16 @@ void MpvObject::handle_mpv_event(mpv_event *event)
if (prop->format == MPV_FORMAT_STRING) {
QMetaObject::invokeMethod(this,"setTitle");
}
} else if (strcmp(prop->name, "chapter-list") == 0 || strcmp(prop->name, "track-list") == 0) {
if (prop->format == MPV_FORMAT_NODE) {
/*
QVariant v = mpv::qt::node_to_variant((mpv_node *)prop->data);
// Abuse JSON support for easily printing the mpv_node contents.
QJsonDocument d = QJsonDocument::fromVariant(v);
printf("Change property %s:\n", QString(prop->name).toStdString().c_str());
printf(d.toJson().data());*/
//QMetaObject::invokeMethod(this,"updatePlaylist");
}
}
break;
}
case MPV_EVENT_SHUTDOWN: {
exit(0);
break;
}
default: {
break;
}
default: ;
// Ignore uninteresting or unknown events.
}
}

View file

@ -9,7 +9,7 @@ import "codes.js" as LanguageCodes
Window {
id: mainWindow
title: "Qt Quick Controls 2"
title: titleLabel.text
visible: true
width: 720
height: 480
@ -189,6 +189,7 @@ Window {
}
function hideControls() {
renderer.setOption("sub-margin-y", "22")
controlsBar.visible = false
controlsBackground.visible = false
titleBar.visible = false
@ -197,6 +198,7 @@ Window {
function showControls() {
updateControls()
renderer.setOption("sub-margin-y", String(controlsBar.height + progressBar.height))
controlsBar.visible = true
controlsBackground.visible = true
titleBar.visible = true
@ -249,7 +251,7 @@ Window {
onClicked: loadDialog.open()
Timer {
id: mouseAreaPlayerTimer
interval: 2000
interval: 1000
running: false
repeat: false
onTriggered: {
@ -477,6 +479,7 @@ Window {
color: "red"
border.color: "red"
}
}
Button {