ui components to control looping on the fly

This commit is contained in:
Chris Cochrun 2022-10-06 03:33:56 -05:00
parent 39ea1eb759
commit a3be06639b
7 changed files with 58 additions and 10 deletions

View file

@ -224,6 +224,7 @@ MpvObject::MpvObject(QQuickItem *parent)
WATCH_PROP_STRING("hwdec") WATCH_PROP_STRING("hwdec")
WATCH_PROP_STRING("hwdec-current") WATCH_PROP_STRING("hwdec-current")
WATCH_PROP_STRING("hwdec-interop") WATCH_PROP_STRING("hwdec-interop")
WATCH_PROP_STRING("loop")
WATCH_PROP_STRING("media-title") WATCH_PROP_STRING("media-title")
WATCH_PROP_STRING("path") WATCH_PROP_STRING("path")
WATCH_PROP_STRING("video-codec") WATCH_PROP_STRING("video-codec")
@ -430,13 +431,14 @@ void MpvObject::handle_mpv_event(mpv_event *event)
else if HANDLE_PROP_STRING("hwdec", hwdec) else if HANDLE_PROP_STRING("hwdec", hwdec)
else if HANDLE_PROP_STRING("hwdec-current", hwdecCurrent) else if HANDLE_PROP_STRING("hwdec-current", hwdecCurrent)
else if HANDLE_PROP_STRING("hwdec-interop", hwdecInterop) else if HANDLE_PROP_STRING("hwdec-interop", hwdecInterop)
else if HANDLE_PROP_STRING("media-title", mediaTitle) else if HANDLE_PROP_STRING("loop", loop)
else if HANDLE_PROP_STRING("path", path) else if HANDLE_PROP_STRING("media-title", mediaTitle)
else if HANDLE_PROP_STRING("video-codec", videoCodec) else if HANDLE_PROP_STRING("path", path)
else if HANDLE_PROP_STRING("video-format", videoFormat) else if HANDLE_PROP_STRING("video-codec", videoCodec)
else if HANDLE_PROP_STRING("video-params/pixelformat", videoParamsPixelformat) else if HANDLE_PROP_STRING("video-format", videoFormat)
else if HANDLE_PROP_STRING("video-out-params/pixelformat", videoOutParamsPixelformat) else if HANDLE_PROP_STRING("video-params/pixelformat", videoParamsPixelformat)
else if HANDLE_PROP_STRING("ytdl-format", ytdlFormat) else if HANDLE_PROP_STRING("video-out-params/pixelformat", videoOutParamsPixelformat)
else if HANDLE_PROP_STRING("ytdl-format", ytdlFormat)
} else if (prop->format == MPV_FORMAT_INT64) { } else if (prop->format == MPV_FORMAT_INT64) {

View file

@ -94,6 +94,7 @@ class MpvObject : public QQuickFramebufferObject
WRITABLE_PROP_STRING("hwdec", hwdec) WRITABLE_PROP_STRING("hwdec", hwdec)
READONLY_PROP_STRING("hwdec-current", hwdecCurrent) READONLY_PROP_STRING("hwdec-current", hwdecCurrent)
READONLY_PROP_STRING("hwdec-interop", hwdecInterop) READONLY_PROP_STRING("hwdec-interop", hwdecInterop)
WRITABLE_PROP_STRING("loop", loop)
READONLY_PROP_STRING("media-title", mediaTitle) READONLY_PROP_STRING("media-title", mediaTitle)
READONLY_PROP_STRING("path", path) READONLY_PROP_STRING("path", path)
READONLY_PROP_STRING("video-codec", videoCodec) READONLY_PROP_STRING("video-codec", videoCodec)

View file

@ -163,6 +163,11 @@ Controls.Page {
print("Slide changed to: " + item.name); print("Slide changed to: " + item.name);
} }
function loopVideo() {
presentation.loopVideo();
pWindow.loopVideo();
}
function editSwitch(item) { function editSwitch(item) {
if (editMode) { if (editMode) {
switch (editType) { switch (editType) {

View file

@ -19,8 +19,6 @@ FocusScope {
property Item slide: previewSlide property Item slide: previewSlide
onActiveFocusChanged: showPassiveNotification("OUCH")
Item { Item {
id: keyHandler id: keyHandler
anchors.fill: parent anchors.fill: parent
@ -65,6 +63,11 @@ FocusScope {
Controls.ToolSeparator {} Controls.ToolSeparator {}
Item { Layout.fillWidth: true } Item { Layout.fillWidth: true }
Controls.ToolSeparator {} Controls.ToolSeparator {}
Controls.ToolButton {
text: "Repeat"
icon.name: "repeat"
onClicked: mainPage.loopVideo()
}
Controls.ToolButton { Controls.ToolButton {
text: "Effects" text: "Effects"
icon.name: "image-auto-adjust" icon.name: "image-auto-adjust"
@ -152,6 +155,13 @@ FocusScope {
live: true live: true
onMoved: changeVidPos(value); onMoved: changeVidPos(value);
} }
Controls.Switch {
text: "Loop"
visible: itemType === "video";
checked: previewSlide.mpvLoop === "inf" ? true : false
onToggled: mainPage.loopVideo()
}
} }
Item { Item {
@ -273,6 +283,10 @@ FocusScope {
previewSlide.loadVideo(); previewSlide.loadVideo();
} }
function loopVideo() {
previewSlide.loopVideo();
}
function stopVideo() { function stopVideo() {
/* showPassiveNotification("Stopping Video") */ /* showPassiveNotification("Stopping Video") */
previewSlide.stopVideo() previewSlide.stopVideo()

View file

@ -79,4 +79,7 @@ Window {
presentationSlide.pauseVideo(); presentationSlide.pauseVideo();
} }
function loopVideo() {
presentationSlide.loopVideo();
}
} }

View file

@ -31,7 +31,7 @@ Item {
//these properties are for giving video info to parents //these properties are for giving video info to parents
property int mpvPosition: mpv.position property int mpvPosition: mpv.position
property int mpvDuration: mpv.duration property int mpvDuration: mpv.duration
property var mpvLoop: mpv.getProperty("loop") property var mpvLoop: mpv.loop
property bool mpvIsPlaying: mpv.isPlaying property bool mpvIsPlaying: mpv.isPlaying
// These properties help to determine the state of the slide // These properties help to determine the state of the slide
@ -167,6 +167,17 @@ Item {
lyrics.text = text lyrics.text = text
} }
function loopVideo() {
if (mpv.getProperty("loop") === "inf") {
showPassiveNotification("already looping");
mpv.setProperty("loop", "no");
}
else {
mpv.setProperty("loop", "inf");
showPassiveNotification("looping video");
}
}
function loadVideo() { function loadVideo() {
mpvLoadingTimer.restart() mpvLoadingTimer.restart()
} }

View file

@ -143,6 +143,18 @@ Item {
onEditingFinished: updateTitle(text); onEditingFinished: updateTitle(text);
} }
Controls.CheckBox {
id: loopCheckBox
Layout.preferredWidth: 300
Layout.fillWidth: true
Layout.leftMargin: 20
Layout.rightMargin: 20
text: "Repeat"
padding: 10
onToggled: showPassiveNotification("BOOM!")
}
RowLayout { RowLayout {
Layout.preferredWidth: 300 Layout.preferredWidth: 300
Layout.fillWidth: true Layout.fillWidth: true