hide back button in toolbar. Not needed or used
[harmattan/cameraplus] / qml / VideoPlayerPage.qml
1 // -*- qml -*-
2
3 /*!
4  * This file is part of CameraPlus.
5  *
6  * Copyright (C) 2012-2013 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 // TODO: error reporting
29
30 Item {
31     id: page
32
33     signal finished
34     property alias source: video.source
35
36     function play() {
37         video.play()
38     }
39
40     MouseArea {
41         anchors.top: parent.top
42         anchors.bottom: toolBar.top
43         anchors.left: parent.left
44         anchors.right: parent.right
45
46         onClicked: toolBar.show = !toolBar.show
47     }
48
49     Timer {
50         id: hideTimer
51         running: toolBar.show
52         interval: 3000
53         onTriggered: toolBar.show = false
54     }
55
56     Video {
57         id: video
58         anchors.fill: parent
59
60         function toggle() {
61             if (!video.paused) {
62                 video.pause()
63             } else {
64                 page.play()
65             }
66         }
67
68         onStopped: page.finished()
69     }
70
71     Connections {
72         target: Qt.application
73         onActiveChanged: {
74             if (!Qt.application.active) {
75                 video.stop()
76             }
77         }
78     }
79
80     CameraToolBar {
81         id: toolBar
82
83         property bool show: true
84
85         hideBack: true
86         expanded: true
87         anchors.bottom: parent.bottom
88         anchors.bottomMargin: show ? 20 : -1 * (height + 20)
89         anchors.left: parent.left
90         anchors.leftMargin: 20
91         opacity: 0.5
92
93         Behavior on anchors.bottomMargin {
94             PropertyAnimation { duration: 200; }
95         }
96
97         items: [
98             ToolIcon {
99                 iconId: "icon-m-toolbar-mediacontrol-stop-white"
100                 onClicked: video.stop()
101             },
102             Slider {
103                 id: slider
104                 height: toolBar.height
105                 anchors.verticalCenter: parent.verticalCenter
106
107                 platformStyle: SliderStyle {
108                     handleBackground: ""
109                     handleBackgroundPressed: ""
110                 }
111
112                 minimumValue: 0
113                 maximumValue: video.duration
114                 value: video.position
115                 orientation: Qt.Horizontal
116
117                 onPressedChanged: {
118                     if (!slider.pressed) {
119                         video.position = slider.value
120                     }
121
122                     hideTimer.restart()
123                 }
124             },
125             ToolIcon {
126                 id: control
127                 iconId: !video.paused ? "icon-m-toolbar-mediacontrol-pause-white"
128                     : "icon-m-toolbar-mediacontrol-play-white"
129                 onClicked: {
130                     video.toggle()
131                     hideTimer.restart()
132                 }
133             }
134         ]
135     }
136 }