Make player stop after playback finished. Make window title same as media title.
This commit is contained in:
parent
14c9ff1b6d
commit
a4957d6219
|
@ -177,12 +177,22 @@ MpvObject::MpvObject(QQuickItem * parent)
|
||||||
#ifndef USE_RENDER
|
#ifndef USE_RENDER
|
||||||
mpv::qt::set_option_variant(mpv, "vo", "opengl-cb");
|
mpv::qt::set_option_variant(mpv, "vo", "opengl-cb");
|
||||||
#endif
|
#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?
|
// Fix?
|
||||||
mpv::qt::set_option_variant(mpv, "ytdl", "yes");
|
mpv::qt::set_option_variant(mpv, "ytdl", "yes");
|
||||||
|
|
||||||
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");
|
||||||
|
@ -319,24 +329,16 @@ void MpvObject::handle_mpv_event(mpv_event *event)
|
||||||
if (prop->format == MPV_FORMAT_STRING) {
|
if (prop->format == MPV_FORMAT_STRING) {
|
||||||
QMetaObject::invokeMethod(this,"setTitle");
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case MPV_EVENT_SHUTDOWN: {
|
case MPV_EVENT_SHUTDOWN: {
|
||||||
exit(0);
|
exit(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default: ;
|
|
||||||
// Ignore uninteresting or unknown events.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import "codes.js" as LanguageCodes
|
||||||
|
|
||||||
Window {
|
Window {
|
||||||
id: mainWindow
|
id: mainWindow
|
||||||
title: "Qt Quick Controls 2"
|
title: titleLabel.text
|
||||||
visible: true
|
visible: true
|
||||||
width: 720
|
width: 720
|
||||||
height: 480
|
height: 480
|
||||||
|
@ -189,6 +189,7 @@ Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideControls() {
|
function hideControls() {
|
||||||
|
renderer.setOption("sub-margin-y", "22")
|
||||||
controlsBar.visible = false
|
controlsBar.visible = false
|
||||||
controlsBackground.visible = false
|
controlsBackground.visible = false
|
||||||
titleBar.visible = false
|
titleBar.visible = false
|
||||||
|
@ -197,6 +198,7 @@ Window {
|
||||||
|
|
||||||
function showControls() {
|
function showControls() {
|
||||||
updateControls()
|
updateControls()
|
||||||
|
renderer.setOption("sub-margin-y", String(controlsBar.height + progressBar.height))
|
||||||
controlsBar.visible = true
|
controlsBar.visible = true
|
||||||
controlsBackground.visible = true
|
controlsBackground.visible = true
|
||||||
titleBar.visible = true
|
titleBar.visible = true
|
||||||
|
@ -249,7 +251,7 @@ Window {
|
||||||
onClicked: loadDialog.open()
|
onClicked: loadDialog.open()
|
||||||
Timer {
|
Timer {
|
||||||
id: mouseAreaPlayerTimer
|
id: mouseAreaPlayerTimer
|
||||||
interval: 2000
|
interval: 1000
|
||||||
running: false
|
running: false
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
@ -477,6 +479,7 @@ Window {
|
||||||
color: "red"
|
color: "red"
|
||||||
border.color: "red"
|
border.color: "red"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
|
|
Loading…
Reference in a new issue