]> git.tdb.fi Git - xinema.git/blob - remote/qml/pages/PlaybackPage.qml
Implement seeking and play/pause controls in the remote
[xinema.git] / remote / qml / pages / PlaybackPage.qml
1 import QtQuick 2.0
2 import Sailfish.Silica 1.0
3 import fi.mikkosoft.xinema 0.1
4
5 Page
6 {
7         id: page
8
9         Column
10         {
11                 width: parent.width
12                 spacing: Theme.paddingLarge
13
14                 PageHeader
15                 {
16                         title: qsTr("Playback")
17                 }
18
19                 Label
20                 {
21                         text: streamControl.title
22                 }
23
24                 Slider
25                 {
26                         id: slider
27                         width: parent.width
28                         minimumValue: 0.0
29                         maximumValue: Math.max(streamControl.duration, 1.0)
30                         valueText:
31                         {
32                                 var secs = Math.round(value);
33                                 var mins = Math.floor(secs/60);
34                                 secs %= 60;
35                                 var hours = Math.floor(mins/60);
36                                 mins %= 60;
37
38                                 var str = "";
39                                 if(hours>0)
40                                 {
41                                         str = hours+":";
42                                         if(mins<10)
43                                                 str += "0";
44                                 }
45
46                                 str += mins+":";
47                                 if(secs<10)
48                                         str += "0";
49
50                                 return str+secs;
51                         }
52
53                         onDownChanged:
54                         {
55                                 if(!down)
56                                         streamControl.position = value;
57                         }
58                 }
59
60                 IconButton
61                 {
62                         id: playPauseButton
63                         anchors.horizontalCenter: parent.horizontalCenter
64                         property string action: (streamControl.playbackState==StreamControl.Playing ? "pause" : "play")
65                         icon.source: "image://theme/icon-l-"+action
66                         onPressed:
67                         {
68                                 if(action=="play")
69                                         streamControl.playbackState = StreamControl.Playing;
70                                 else if(action=="pause")
71                                         streamControl.playbackState = StreamControl.Paused;
72                         }
73                 }
74         }
75
76         StreamControl
77         {
78                 id: streamControl
79                 control: xinemaControl
80                 onPositionChanged:
81                 {
82                         if(!slider.down)
83                                 slider.value = position;
84                 }
85         }
86 }