/*!
* This file is part of CameraPlus.
*
- * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-import QtQuick 1.1
-import com.nokia.meego 1.1
-import QtMultimediaKit 1.1
+import QtQuick 2.0
import CameraPlus 1.0
-
-// TODO: error reporting
-
-CameraPage {
- id: page
-
- property bool popTwice: false
- controlsVisible: false
- policyMode: CameraResources.PostCapture
- needsPipeline: false
- standbyVisible: false
-
- property alias source: video.source
- function play() {
- video.play();
+import QtCamera 1.0
+import QtCameraExtras 1.0
+
+Item {
+ id: page
+
+ signal finished
+ property alias source: video.source
+
+ function play() {
+ return video.play()
+ }
+
+ function stop() {
+ return video.stop()
+ }
+
+ MouseArea {
+ anchors.top: parent.top
+ anchors.bottom: toolBar.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+
+ onClicked: toolBar.show = !toolBar.show
+ }
+
+ Timer {
+ id: hideTimer
+ running: toolBar.show
+ interval: 3000
+ onTriggered: toolBar.show = false
+ }
+
+ VideoPlayer {
+ id: video
+ anchors.fill: parent
+ cameraConfig: camera.cameraConfig
+
+ onError: showError(qsTr("Error playing video. Please try again or restart the application"))
+
+ function toggle() {
+ if (state != VideoPlayer.StatePaused) {
+ video.pause()
+ } else {
+ page.play()
+ }
}
- MouseArea {
- anchors.top: parent.top
- anchors.bottom: toolBar.top
- anchors.left: parent.left
- anchors.right: parent.right
-
- onClicked: toolBar.show = !toolBar.show
+ onStateChanged: {
+ if (state == VideoPlayer.StateStopped) {
+ page.finished()
+ }
}
-
- Timer {
- id: hideTimer
- running: toolBar.show
- interval: 3000
- onTriggered: toolBar.show = false;
+ }
+
+ Connections {
+ target: Qt.application
+ onActiveChanged: {
+ if (!Qt.application.active) {
+ video.stop()
+ }
}
+ }
- Video {
- id: video
- anchors.fill: parent
-
- function toggle() {
- if (!video.paused) {
- video.pause();
- }
- else {
- video.play();
- }
- }
+ CameraToolBar {
+ id: toolBar
- onStopped: {
- source = "";
- pageStack.pop(undefined, true);
+ property bool show: true
- if (page.popTwice) {
- pageStack.pop(undefined);
- }
- }
- }
-
- Connections {
- target: Qt.application
- onActiveChanged: {
- if (!Qt.application.active) {
- video.stop();
- }
- }
+ hideBack: true
+ expanded: true
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: show ? 20 : -1 * (height + 20)
+ anchors.left: parent.left
+ anchors.leftMargin: 20
+ opacity: 0.5
+
+ Behavior on anchors.bottomMargin {
+ PropertyAnimation { duration: 200; }
}
- CameraToolBar {
- id: toolBar
+ tools: CameraToolBarTools {
+ CameraToolIcon {
+ iconSource: cameraTheme.videoStopIconId
+ onClicked: video.stop()
+ }
- property bool show: true
+ CameraSlider {
+ id: slider
+ height: toolBar.height
+ anchors.verticalCenter: parent.verticalCenter
- manualBack: true
- expanded: true
- anchors.bottom: parent.bottom
- anchors.bottomMargin: show ? 20 : -1 * (height + 20)
- anchors.left: parent.left
- anchors.leftMargin: 20
- opacity: 0.5
+ handleBackground: ""
+ handleBackgroundPressed: ""
- Behavior on anchors.bottomMargin {
- PropertyAnimation { duration: 200; }
+ minimumValue: 0
+ maximumValue: video.duration
+ value: video.position
+ orientation: Qt.Horizontal
+
+ onPressedChanged: {
+ if (!slider.pressed) {
+ video.position = slider.value
+ }
+
+ hideTimer.restart()
}
+ }
+ CameraToolIcon {
+ id: control
+ iconSource: video.state != VideoPlayer.StatePaused ? cameraTheme.videoPauseIconId : cameraTheme.videoPlayIconId
onClicked: {
- page.popTwice = true;
- video.stop();
+ video.toggle()
+ hideTimer.restart()
}
-
- items: [
- ToolIcon { iconId: "icon-m-toolbar-mediacontrol-stop-white"; onClicked: { video.stop(); } },
- Slider {
- id: slider
- height: toolBar.height
- anchors.verticalCenter: parent.verticalCenter
-
- platformStyle: SliderStyle {
- handleBackground: ""
- handleBackgroundPressed: ""
- }
-
- minimumValue: 0
- maximumValue: video.duration
- value: video.position
- orientation: Qt.Horizontal
-
- onPressedChanged: {
- if (!slider.pressed) {
- video.position = slider.value;
- }
-
- hideTimer.restart();
- }
- },
- ToolIcon {
- id: control
- iconId: !video.paused ? "icon-m-toolbar-mediacontrol-pause-white" : "icon-m-toolbar-mediacontrol-play-white"
- onClicked: {
- video.toggle();
- hideTimer.restart();
- }
- }
- ]
+ }
}
+ }
}