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
32 // TODO: optional resources?
38 Component.onDestruction: videoMode.stopRecording();
41 if (page.status == PageStatus.Active) {
46 function startRecording() {
47 if (!pipelineManager.acquired || pipelineManager.hijacked) {
48 showError(qsTr("Failed to acquire needed resources."));
49 pageStack.pop(undefined, true);
53 metaData.setMetaData();
55 if (!mountProtector.lock()) {
56 showError(qsTr("Failed to lock images directory."));
57 pageStack.pop(undefined, true);
61 var file = fileNaming.videoFileName();
62 var tmpFile = fileNaming.temporaryVideoFileName();
64 if (!videoMode.startRecording(file, tmpFile)) {
65 showError(qsTr("Failed to record video. Please restart the camera."));
66 pageStack.pop(undefined, true);
67 mountProtector.unlock();
70 // TODO: sometimes this fails (fast stop after start).
71 trackerStore.storeVideo(file);
74 function stopRecording() {
75 mountProtector.unlock();
76 pageStack.pop(undefined, true);
79 policyMode: CameraResources.Recording
81 controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
83 orientationLock: PageOrientation.LockLandscape
90 if (!checkBattery()) {
92 showError(qsTr("Not enough battery to record video."));
98 anchors.right: parent.right
99 anchors.rightMargin: 20
100 anchors.verticalCenter: parent.verticalCenter
101 iconSource: "image://theme/icon-m-camera-video-record"
106 onClicked: page.stopRecording();
107 visible: controlsVisible
111 target: Qt.application
113 if (!Qt.application.active) {
114 page.stopRecording();
127 visible: controlsVisible
128 anchors.top: parent.top
129 anchors.left: parent.left
130 anchors.topMargin: 20
131 anchors.leftMargin: 20
137 visible: controlsVisible
138 anchors.top: torch.bottom
139 anchors.left: parent.left
140 anchors.topMargin: 10
141 anchors.leftMargin: 20
145 anchors.left: parent.left
146 anchors.bottom: parent.bottom
147 anchors.leftMargin: 20
148 anchors.bottomMargin: 20
150 visible: controlsVisible
158 id: recordingDuration
160 property int duration: 0
162 running: videoMode.recording
167 duration = duration + 1;
168 if (duration == 3600) {
169 page.stopRecording();
170 showError(qsTr("Maximum recording time reached."));
172 else if (!checkDiskSpace()) {
173 page.stopRecording();
174 showError(qsTr("Not enough space to continue recording."));
181 source: "image://theme/icon-m-camera-ongoing-recording"
184 anchors.verticalCenter: parent.verticalCenter
185 anchors.left: parent.left
186 anchors.leftMargin: 5
188 sourceSize.height: 20
192 function formatDuration(dur) {
193 var secs = parseInt(recordingDuration.duration);
194 var minutes = Math.floor(secs / 60);
195 var seconds = secs - (minutes * 60);
197 var date = new Date();
198 date.setSeconds(seconds);
199 date.setMinutes(minutes);
200 return Qt.formatTime(date, "mm:ss");
204 text: formatDuration(recordingDuration.duration);
205 anchors.left: recordingIcon.right
206 anchors.leftMargin: 5