Skip to content

Commit dde9a80

Browse files
committed
feat: allow to loop specific videos until manual skip
1 parent 93b79bc commit dde9a80

4 files changed

Lines changed: 35 additions & 16 deletions

File tree

package/contents/ui/FadePlayer.qml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Item {
5555
function stop() {
5656
player.stop();
5757
}
58-
function next(switchSource) {
59-
if (switchSource) {
58+
function next(switchSource, forceSwitch) {
59+
if ((switchSource && !currentSource.loop) || forceSwitch) {
6060
setNextSource();
6161
}
6262
if (primaryPlayer) {
@@ -113,7 +113,7 @@ Item {
113113
opacity: 1
114114
fillMode: root.fillMode
115115
loops: {
116-
if(!root.multipleVideos)
116+
if(!root.multipleVideos || (root.currentSource.loop && !root.crossfadeEnabled))
117117
return MediaPlayer.Infinite;
118118
else if(root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow)
119119
return 1;
@@ -202,7 +202,7 @@ Item {
202202
z: 1
203203
fillMode: root.fillMode
204204
loops: {
205-
if(!root.multipleVideos)
205+
if(!root.multipleVideos || (root.currentSource.loop && !root.crossfadeEnabled))
206206
return MediaPlayer.Infinite;
207207
else if(root.changeWallpaperMode === Enum.ChangeWallpaperMode.Slideshow)
208208
return 1;
@@ -269,7 +269,7 @@ Item {
269269
text: root.player.source
270270
}
271271
PlasmaComponents.Label {
272-
text: main.currentVideoIndex
272+
text: "currentVideoIndex " + main.currentVideoIndex
273273
}
274274
PlasmaComponents.Label {
275275
text: "changeWallpaperMode " + root.changeWallpaperMode
@@ -290,7 +290,10 @@ Item {
290290
text: "media status " + root.player.mediaStatus
291291
}
292292
PlasmaComponents.Label {
293-
text: "playing " + root.player.playing
293+
text: "player1 playing " + videoPlayer1.playing
294+
}
295+
PlasmaComponents.Label {
296+
text: "player2 playing " + videoPlayer2.playing
294297
}
295298
PlasmaComponents.Label {
296299
text: "position " + root.player.position

package/contents/ui/code/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function createVideo(filename) {
2929
"duration": 0,
3030
"customDuration": 0,
3131
"playbackRate": 0.0,
32+
"loop": false
3233
};
3334
}
3435

package/contents/ui/config.qml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ Kirigami.FormLayout {
210210
icon.name: "preferences-other"
211211
enabled: true
212212
onClicked: {
213-
dialogPlaybackRateSpeed.value = videosConfig[modelData].playbackRate;
214-
videoConfig.filename = videosConfig[modelData].filename;
215-
videoConfig.index = index;
216-
videoConfig.open();
213+
videoConfigDialog.playbackRate = videosConfig[modelData].playbackRate;
214+
videoConfigDialog.loop = videosConfig[modelData].loop ?? false;
215+
videoConfigDialog.index = index;
216+
videoConfigDialog.open();
217217
}
218218
}
219219
}
@@ -804,26 +804,30 @@ Kirigami.FormLayout {
804804
}
805805

806806
Kirigami.Dialog {
807-
id: videoConfig
807+
id: videoConfigDialog
808808
standardButtons: Kirigami.Dialog.Ok | Kirigami.Dialog.Cancel
809809
title: i18n("Video Settings")
810810
padding: Kirigami.Units.largeSpacing
811811

812812
property int index
813-
property real speed
813+
property real playbackRate
814+
property bool loop
814815
property string filename: ""
815816

816817
Kirigami.FormLayout {
818+
Label {
819+
text: videoConfigDialog.filename
820+
}
817821
RowLayout {
818822
Kirigami.FormData.label: i18n("Playback speed:")
819823
Slider {
820824
id: dialogPlaybackRateSpeed
821825
from: 0
822826
to: 2
823827
stepSize: 0.05
824-
value: videoConfig.speed
828+
value: videoConfigDialog.playbackRate
825829
onValueChanged: {
826-
videoConfig.speed = value;
830+
videoConfigDialog.playbackRate = value;
827831
}
828832
Layout.preferredWidth: 200
829833
}
@@ -846,10 +850,21 @@ Kirigami.FormLayout {
846850
toolTipText: i18n("A value other than 0.0 overrides the global Playback speed for this video.")
847851
}
848852
}
853+
RowLayout {
854+
Kirigami.FormData.label: i18n("Loop:")
855+
CheckBox {
856+
checked: videoConfigDialog.loop
857+
onCheckedChanged: videoConfigDialog.loop = checked
858+
}
859+
Kirigami.ContextualHelpButton {
860+
toolTipText: i18n("If enabled the video will loop continuously instead of playing the next one.<br>Use the <strong>Next Video</strong> option to play the next video in the list.")
861+
}
862+
}
849863
}
850864

851865
onAccepted: {
852-
videosConfig[index].playbackRate = speed;
866+
root.videosConfig[index].playbackRate = playbackRate;
867+
root.videosConfig[index].loop = loop;
853868
Utils.updateConfig();
854869
}
855870
}

package/contents/ui/main.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ WallpaperItem {
387387
text: i18n("Next Video")
388388
icon.name: "media-skip-forward"
389389
onTriggered: {
390-
player.next(true);
390+
player.next(true, true);
391391
}
392392
visible: player.multipleVideos
393393
},

0 commit comments

Comments
 (0)