X-Git-Url: http://cgit.sxemacs.org/?p=harmattan%2Fcameraplus;a=blobdiff_plain;f=qml%2FVideoPlayerPage.qml;h=c87e50791153dcfbefbb6d7e943320dff4d2c2f3;hp=6e7eaae528a73394c1c24c4cee8358e505cc7cb0;hb=8828a801c6a29497e298ef0587424bef10beeaa0;hpb=57c992a3c7bdf7ee97e3b4ab15fbf2903026f63a diff --git a/qml/VideoPlayerPage.qml b/qml/VideoPlayerPage.qml index 6e7eaae..c87e507 100644 --- a/qml/VideoPlayerPage.qml +++ b/qml/VideoPlayerPage.qml @@ -3,7 +3,7 @@ /*! * This file is part of CameraPlus. * - * Copyright (C) 2012 Mohammed Sameer + * Copyright (C) 2012-2013 Mohammed Sameer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -22,114 +22,121 @@ import QtQuick 1.1 import com.nokia.meego 1.1 -import QtMultimediaKit 1.1 import CameraPlus 1.0 - -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() + } + + 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: cam.cameraConfig + + onError: showError(qsTr("Error playing video. Please try again or restart the application")) + + function toggle() { + if (!video.paused) { + 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() + } } + } + + 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; } } - // TODO: auto-hide this - CameraToolBar { - id: toolBar + 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: "" + } - property bool show: true + minimumValue: 0 + maximumValue: video.duration + value: video.position + orientation: Qt.Horizontal - 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 + onPressedChanged: { + if (!slider.pressed) { + video.position = slider.value + } - Behavior on anchors.bottomMargin { - PropertyAnimation { duration: 200; } + hideTimer.restart() } - + }, + ToolIcon { + id: control + iconId: !video.paused ? "icon-m-toolbar-mediacontrol-pause-white" + : "icon-m-toolbar-mediacontrol-play-white" 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; - } - } - }, - ToolIcon { - id: control - iconId: !video.paused ? "icon-m-toolbar-mediacontrol-pause-white" : "icon-m-toolbar-mediacontrol-play-white"; onClicked: video.toggle(); - } - ] - } + } + ] + } }