Warning, /graphics/koko/src/qml/imagedelegate/VideoDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: (C) 2015 Vishesh Handa <vhanda@kde.org> 0003 * SPDX-FileCopyrightText: (C) 2017 Atul Sharma <atulsharma406@gmail.com> 0004 * SPDX-FileCopyrightText: (C) 2017 Marco Martin <mart@kde.org> 0005 * SPDX-FileCopyrightText: (C) 2021 Noah Davis <noahadvs@gmail.com> 0006 * SPDX-FileCopyrightText: (C) 2021 Mikel Johnson <mikel5764@gmail.com> 0007 * SPDX-FileCopyrightText: (C) 2021 Arjen Hiemstra <ahiemstra@heimr.nl> 0008 * 0009 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0010 */ 0011 0012 import QtQuick 2.15 0013 import QtQml 2.15 0014 import QtMultimedia 5.15 0015 import org.kde.kirigami 2.15 as Kirigami 0016 import org.kde.koko 0.1 0017 0018 BaseImageDelegate { 0019 id: root 0020 0021 required property bool autoplay 0022 required property Item slideShow 0023 0024 loaded: player.status == MediaPlayer.Loaded 0025 loading: player.status == MediaPlayer.Loading 0026 0027 sourceWidth: player.implicitWidth 0028 sourceHeight: player.implicitHeight 0029 0030 enabled: false 0031 0032 data: VideoPlayer { 0033 id: player 0034 0035 anchors.fill: parent 0036 0037 source: root.source 0038 0039 onPlaybackStarted: { 0040 if (!root.isCurrent) { 0041 return; 0042 } 0043 // indicate that we're running a video 0044 if (root.slideShow.running) { 0045 root.slideShow.externalPlaybackStarted(); 0046 } 0047 } 0048 onPlaybackFinished: { 0049 if (!root.isCurrent) { 0050 return; 0051 } 0052 // indicate that we stopped playing the video 0053 if (root.slideShow.externalMediaRunning) { 0054 root.slideShow.externalPlaybackFinished(); 0055 } 0056 } 0057 // in case loader takes it's sweet time to load 0058 Component.onCompleted: { 0059 if (root.autoplay || (root.slideShow.running && root.isCurrent)) { 0060 play(); 0061 root.autoplay = false; 0062 } 0063 } 0064 } 0065 0066 onAutoplayChanged: { 0067 if (autoplay) { // play video automatically if started with "open with..." 0068 player.play(); 0069 autoplay = false; 0070 } 0071 } 0072 0073 onIsCurrentChanged: slideshowAutoplay() 0074 onSlideShowChanged: slideshowAutoplay() 0075 0076 function slideshowAutoplay() { 0077 if (isCurrent && slideShow && slideShow.running) { 0078 player.play() 0079 } else { 0080 player.stop() 0081 } 0082 } 0083 0084 Connections { 0085 target: root.slideShow 0086 function onRunningChanged() { 0087 // start playback if slideshow is running 0088 if (root.slideShow.running && root.isCurrent) { 0089 if (player.playing) { // indicate that video is already playing 0090 root.slideShow.externalPlaybackStarted(); 0091 } else { 0092 player.play(); 0093 } 0094 } 0095 } 0096 } 0097 0098 Component.onDestruction: { 0099 // indicate playback being finished if delegate that started it was unloaded (i.e. by using thumbnail bar) 0100 if (slideShow.externalMediaRunning) { 0101 slideShow.externalPlaybackUnloaded() 0102 } 0103 } 0104 }