4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 property url itemUrl: url
30 property string itemTitle: title
31 property string itemMimeType: mimeType
32 property string itemCreated: created
33 property string itemFileName: fileName
35 property bool isVideo: itemMimeType.search("video/") >= 0
36 property alias error: image.error
37 property bool playing: loader.source != ""
41 function startPlayback() {
42 loader.source = Qt.resolvedUrl("VideoPlayerPage.qml")
43 loader.item.source = itemUrl
44 if (!loader.item.play()) {
45 showError(qsTr("Error playing video. Please try again."))
50 function stopPlayback() {
63 onFinished: loader.source = ""
69 mimeType: itemMimeType
70 rotation: calculateRotation(orientation.orientation)
71 width: isPortrait ? parent.height : parent.width - 10
72 height: isPortrait ? parent.width - 10 : parent.height
73 anchors.centerIn: parent
74 visible: loader.source == ""
75 property bool isPortrait: rotation == -90
78 PropertyAnimation { duration: 100 }
82 PropertyAnimation { duration: 100 }
85 Behavior on rotation {
86 PropertyAnimation { duration: 100 }
89 function calculateRotation(orientation) {
90 switch (orientation) {
91 case CameraOrientation.InvertedLandscape:
92 case CameraOrientation.Landscape:
94 case CameraOrientation.InvertedPortrait:
95 case CameraOrientation.Portrait:
106 onClicked: postCaptureItem.clicked()
110 anchors.centerIn: parent
117 text: qsTr("Failed to load preview")
118 verticalAlignment: Text.AlignVCenter
119 horizontalAlignment: Text.AlignHCenter
125 anchors.horizontalCenter: parent.horizontalCenter
126 iconSource: cameraTheme.videoPlayIconId
128 onClicked: startPlayback()