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?
33 // TODO: get touch focus settings from VideoPage
39 Component.onDestruction: videoMode.stopRecording();
42 if (page.status == PageStatus.Active) {
47 function startRecording() {
48 if (!pipelineManager.acquired || pipelineManager.hijacked) {
49 showError(qsTr("Failed to acquire needed resources."));
50 pageStack.pop(undefined, true);
54 metaData.setMetaData();
56 if (!mountProtector.lock()) {
57 showError(qsTr("Failed to lock images directory."));
58 pageStack.pop(undefined, true);
62 var file = fileNaming.videoFileName();
63 var tmpFile = fileNaming.temporaryVideoFileName();
65 if (!videoMode.startRecording(file, tmpFile)) {
66 showError(qsTr("Failed to record video. Please restart the camera."));
67 pageStack.pop(undefined, true);
68 mountProtector.unlock();
71 // TODO: sometimes this fails (fast stop after start).
72 trackerStore.storeVideo(file);
75 function stopRecording() {
76 mountProtector.unlock();
77 pageStack.pop(undefined, true);
80 policyMode: CameraResources.Recording
82 controlsVisible: cam.running && videoMode.recording && !cameraMode.animationRunning && !previewAnimationRunning && !standbyWidget.visible
84 orientationLock: PageOrientation.LockLandscape
91 if (!checkBattery()) {
93 showError(qsTr("Not enough battery to record video."));
99 anchors.right: parent.right
100 anchors.rightMargin: 20
101 anchors.verticalCenter: parent.verticalCenter
102 iconSource: "image://theme/icon-m-camera-video-record"
107 onClicked: page.stopRecording();
108 visible: controlsVisible
112 target: Qt.application
114 if (!Qt.application.active) {
115 page.stopRecording();
128 visible: controlsVisible
129 anchors.top: parent.top
130 anchors.left: parent.left
131 anchors.topMargin: 20
132 anchors.leftMargin: 20
138 visible: controlsVisible
139 anchors.top: torch.bottom
140 anchors.left: parent.left
141 anchors.topMargin: 10
142 anchors.leftMargin: 20
146 anchors.left: parent.left
147 anchors.bottom: parent.bottom
148 anchors.leftMargin: 20
149 anchors.bottomMargin: 20
151 visible: controlsVisible
159 id: recordingDuration
161 property int duration: 0
163 running: videoMode.recording
168 duration = duration + 1;
169 if (duration == 3600) {
170 page.stopRecording();
171 showError(qsTr("Maximum recording time reached."));
173 else if (!checkDiskSpace()) {
174 page.stopRecording();
175 showError(qsTr("Not enough space to continue recording."));
182 source: "image://theme/icon-m-camera-ongoing-recording"
185 anchors.verticalCenter: parent.verticalCenter
186 anchors.left: parent.left
187 anchors.leftMargin: 5
189 sourceSize.height: 20
193 function formatDuration(dur) {
194 var secs = parseInt(recordingDuration.duration);
195 var minutes = Math.floor(secs / 60);
196 var seconds = secs - (minutes * 60);
198 var date = new Date();
199 date.setSeconds(seconds);
200 date.setMinutes(minutes);
201 return Qt.formatTime(date, "mm:ss");
205 text: formatDuration(recordingDuration.duration);
206 anchors.left: recordingIcon.right
207 anchors.leftMargin: 5