2
* Copyright (C) 2013 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import QtMultimedia 5.0
22
VideoViewerDelegate is an item to show a vide thumbnail, and play the video
26
id: videoViewerDelegate
28
/// The video item that to be shown by this component
29
property MediaSource mediaSource
30
/// Is true, once this component is fully usable
31
property bool isLoaded: thumbnail.status === Image.Ready
33
/// Stops the video playback if running
38
/// Starts playing the video
39
function playVideo() {
40
if (!loader_video.item)
41
loader_video.sourceComponent = component_video;
43
if (loader_video.item.source !== mediaSource.path)
44
loader_video.item.source = mediaSource.path;
45
loader_video.item.play();
48
/// Toggles between playing and pausing the video playback
49
function togglePlayPause() {
50
if (!loader_video.item)
51
loader_video.sourceComponent = component_video;
53
if (videoViewerDelegate.state === "playing") {
54
loader_video.item.pause();
56
videoViewerDelegate.playVideo();
64
fillMode: Image.PreserveAspectFit
65
source: mediaSource.galleryPreviewPath
70
// Display a play icon if the media is a video
71
source: "../../img/icon_play.png"
72
anchors.centerIn: parent
78
videoViewerDelegate.togglePlayPause();
87
videoViewerDelegate.state = "stopped";
90
videoViewerDelegate.state = "paused"
93
videoViewerDelegate.state = "playing"
107
PropertyChanges { target: thumbnail; visible: false }
111
PropertyChanges { target: thumbnail; visible: false }
115
PropertyChanges { target: thumbnail; visible: true }
119
if (state === "stopped") {
120
if (loader_video.item)
121
loader_video.item.stop()
122
loader_video.sourceComponent = null