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();
63 function stopRecording() {
64 mountProtector.unlock();
65 pageStack.pop(undefined, true);
68 policyMode: CameraResources.Recording
70 controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
72 orientationLock: PageOrientation.LockLandscape
79 if (!checkBattery()) {
81 showError(qsTr("Not enough battery to record video."));
87 anchors.right: parent.right
88 anchors.rightMargin: 20
89 anchors.verticalCenter: parent.verticalCenter
90 iconSource: "image://theme/icon-m-camera-video-record"
95 onClicked: page.stopRecording();
96 visible: controlsVisible
100 target: Qt.application
102 if (!Qt.application.active) {
103 page.stopRecording();
116 visible: controlsVisible
117 anchors.top: parent.top
118 anchors.left: parent.left
119 anchors.topMargin: 20
120 anchors.leftMargin: 20
126 visible: controlsVisible
127 anchors.top: torch.bottom
128 anchors.left: parent.left
129 anchors.topMargin: 10
130 anchors.leftMargin: 20
134 anchors.left: parent.left
135 anchors.bottom: parent.bottom
136 anchors.leftMargin: 20
137 anchors.bottomMargin: 20
139 visible: controlsVisible
147 id: recordingDuration
149 property int duration: 0
151 running: videoMode.recording
156 duration = duration + 1;
157 if (duration == 3600) {
158 page.stopRecording();
159 showError(qsTr("Maximum recording time reached."));
161 else if (!checkDiskSpace()) {
162 page.stopRecording();
163 showError(qsTr("Not enough space to continue recording."));
170 source: "image://theme/icon-m-camera-ongoing-recording"
173 anchors.verticalCenter: parent.verticalCenter
174 anchors.left: parent.left
175 anchors.leftMargin: 5
177 sourceSize.height: 20
181 function formatDuration(dur) {
182 var secs = parseInt(recordingDuration.duration);
183 var minutes = Math.floor(secs / 60);
184 var seconds = secs - (minutes * 60);
186 var date = new Date();
187 date.setSeconds(seconds);
188 date.setMinutes(minutes);
189 return Qt.formatTime(date, "mm:ss");
193 text: formatDuration(recordingDuration.duration);
194 anchors.left: recordingIcon.right
195 anchors.leftMargin: 5