4 * This file is part of CameraPlus.
6 * Copyright (C) 2012 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
24 import com.nokia.meego 1.1
27 import "data.js" as Data
30 // TODO: resources lost?
31 // TODO: closing camera in the middle of recording will hang camera
36 Component.onCompleted: startRecording();
37 Component.onDestruction: videoMode.stopRecording();
39 function startRecording() {
40 if (!resourcePolicy.acquired || resourcePolicy.hijacked) {
41 pageStack.pop(undefined, true);
45 metaData.setMetaData();
47 if (!mountProtector.lock()) {
48 showError(qsTr("Failed to lock images directory."));
49 pageStack.pop(undefined, true);
53 var file = fileNaming.videoFileName();
54 var tmpFile = fileNaming.temporaryVideoFileName();
56 if (!videoMode.startRecording(file, tmpFile)) {
57 showError(qsTr("Failed to record video. Please restart the camera."));
58 pageStack.pop(undefined, true);
59 mountProtector.unlock();
62 trackerStore.storeVideo(file);
65 function stopRecording() {
66 mountProtector.unlock();
67 pageStack.pop(undefined, true);
70 policyMode: CameraResources.Recording
72 controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
74 orientationLock: PageOrientation.LockLandscape
81 if (!checkBattery()) {
83 showError(qsTr("Not enough battery to record video."));
89 anchors.right: parent.right
90 anchors.rightMargin: 20
91 anchors.verticalCenter: parent.verticalCenter
92 iconSource: "image://theme/icon-m-camera-video-record"
97 onClicked: page.stopRecording();
98 visible: controlsVisible
102 target: Qt.application
104 if (!Qt.application.active) {
105 page.stopRecording();
118 visible: controlsVisible
119 anchors.top: parent.top
120 anchors.left: parent.left
121 anchors.topMargin: 20
122 anchors.leftMargin: 20
128 visible: controlsVisible
129 anchors.top: torch.bottom
130 anchors.left: parent.left
131 anchors.topMargin: 10
132 anchors.leftMargin: 20
136 anchors.left: parent.left
137 anchors.bottom: parent.bottom
138 anchors.leftMargin: 20
139 anchors.bottomMargin: 20
141 visible: controlsVisible
149 id: recordingDuration
151 property int duration: 0
153 running: videoMode.recording
158 duration = duration + 1;
159 if (duration == 3600) {
160 page.stopRecording();
161 showError(qsTr("Maximum recording time reached."));
163 else if (!checkDiskSpace()) {
164 page.stopRecording();
165 showError(qsTr("Not enough space to continue recording."));
172 source: "image://theme/icon-m-camera-ongoing-recording"
175 anchors.verticalCenter: parent.verticalCenter
176 anchors.left: parent.left
177 anchors.leftMargin: 5
179 sourceSize.height: 20
183 function formatDuration(dur) {
184 var secs = parseInt(recordingDuration.duration);
185 var minutes = Math.floor(secs / 60);
186 var seconds = secs - (minutes * 60);
188 var date = new Date();
189 date.setSeconds(seconds);
190 date.setMinutes(minutes);
191 return Qt.formatTime(date, "mm:ss");
195 text: formatDuration(recordingDuration.duration);
196 anchors.left: recordingIcon.right
197 anchors.leftMargin: 5