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?
35 Component.onCompleted: startRecording();
36 Component.onDestruction: videoMode.stopRecording();
38 function startRecording() {
39 if (!resourcePolicy.acquired || resourcePolicy.hijacked) {
40 pageStack.pop(undefined, true);
44 metaData.setMetaData();
46 if (!mountProtector.lock()) {
47 showError(qsTr("Failed to lock images directory."));
48 pageStack.pop(undefined, true);
52 var file = fileNaming.videoFileName();
53 var tmpFile = fileNaming.temporaryVideoFileName();
55 if (!videoMode.startRecording(file, tmpFile)) {
56 showError(qsTr("Failed to record video. Please restart the camera."));
57 pageStack.pop(undefined, true);
58 mountProtector.unlock();
62 function stopRecording() {
63 mountProtector.unlock();
64 pageStack.pop(undefined, true);
67 policyMode: CameraResources.Recording
69 controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
71 orientationLock: PageOrientation.LockLandscape
78 if (!checkBattery()) {
80 showError(qsTr("Not enough battery to record video."));
86 anchors.right: parent.right
87 anchors.rightMargin: 20
88 anchors.verticalCenter: parent.verticalCenter
89 iconSource: "image://theme/icon-m-camera-video-record"
94 onClicked: page.stopRecording();
95 visible: controlsVisible
99 target: Qt.application
101 if (!Qt.application.active) {
102 page.stopRecording();
115 visible: controlsVisible
116 anchors.top: parent.top
117 anchors.left: parent.left
118 anchors.topMargin: 20
119 anchors.leftMargin: 20
125 visible: controlsVisible
126 anchors.top: torch.bottom
127 anchors.left: parent.left
128 anchors.topMargin: 10
129 anchors.leftMargin: 20
133 anchors.left: parent.left
134 anchors.bottom: parent.bottom
135 anchors.leftMargin: 20
136 anchors.bottomMargin: 20
138 visible: controlsVisible
146 id: recordingDuration
148 property int duration: 0
150 running: videoMode.recording
155 duration = duration + 1;
156 if (duration == 3600) {
157 page.stopRecording();
158 showError(qsTr("Maximum recording time reached."));
160 else if (!checkDiskSpace()) {
161 page.stopRecording();
162 showError(qsTr("Not enough space to continue recording."));
169 source: "image://theme/icon-m-camera-ongoing-recording"
172 anchors.verticalCenter: parent.verticalCenter
173 anchors.left: parent.left
174 anchors.leftMargin: 5
176 sourceSize.height: 20
180 function formatDuration(dur) {
181 var secs = parseInt(recordingDuration.duration);
182 var minutes = Math.floor(secs / 60);
183 var seconds = secs - (minutes * 60);
185 var date = new Date();
186 date.setSeconds(seconds);
187 date.setMinutes(minutes);
188 return Qt.formatTime(date, "mm:ss");
192 text: formatDuration(recordingDuration.duration);
193 anchors.left: recordingIcon.right
194 anchors.leftMargin: 5