Reworked ModeButton to use a Switch
[harmattan/cameraplus] / qml / VideoPlayerPage.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
7  *
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.
12  *
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.
17  *
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
21  */
22
23 import QtQuick 1.1
24 import com.nokia.meego 1.1
25 import QtMultimediaKit 1.1
26 import CameraPlus 1.0
27
28 CameraPage {
29         id: page
30
31         controlsVisible: false
32         policyMode: CameraResources.PostCapture
33         needsPipeline: false
34         standbyVisible: false
35
36         property alias source: video.source
37         function play() {
38                 video.play();
39         }
40
41         MouseArea {
42                 anchors.fill: parent
43                 onClicked: toolBar.visible = !toolBar.visible
44         }
45
46                 Video {
47                 id: video
48                 anchors.fill: parent
49                 onStopped: pageStack.pop(undefined, true);
50                 }
51
52         Connections {
53                 target: Qt.application
54                 onActiveChanged: {
55                         if (!Qt.application.active) {
56                                 video.stop();
57                         }
58                 }
59         }
60
61         ToolBar {
62                 id: toolBar
63                 opacity: 0.8
64                 anchors.bottom: parent.bottom
65                 tools: ToolBarLayout {
66                         id: layout
67
68                         ToolIcon { iconId: "icon-m-toolbar-mediacontrol-stop-white"; onClicked: { video.stop(); } }
69
70                         Slider {
71                                 id: slider
72                                 height: toolBar.height
73
74                                 platformStyle: SliderStyle {
75                                         // HACK
76                                         handleBackground: " "
77                                         handleBackgroundPressed: " "
78                                 }
79
80                                 minimumValue: 0
81                                 maximumValue: video.duration
82                                 value: video.position
83                                 orientation: Qt.Horizontal
84
85                                 onPressedChanged: {
86                                         if (!slider.pressed) {
87                                                 video.position = slider.value;
88                                         }
89                                 }
90                         }
91
92                         ToolIcon {
93                                 id: control
94                                 iconId: !video.paused ? "icon-m-toolbar-mediacontrol-pause-white" : "icon-m-toolbar-mediacontrol-play-white"
95                                 onClicked: {
96                                         if (!video.paused) {
97                                                 video.pause();
98                                         }
99                                         else {
100                                                 video.play();
101                                         }
102                                 }
103                         }
104                 }
105         }
106 }