]> git.tdb.fi Git - xinema.git/blob - remote/qml/pages/PlaybackPage.qml
Fine-tune PlaybackPage layout
[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                         anchors
23                         {
24                                 left: parent.left
25                                 right: parent.right
26                                 margins: Theme.horizontalPageMargin
27                         }
28                         horizontalAlignment: Text.AlignHCenter
29                         wrapMode: Text.WordWrap
30                 }
31
32                 Slider
33                 {
34                         id: slider
35                         width: parent.width
36
37                         minimumValue: 0.0
38                         maximumValue: Math.max(streamControl.duration, 1.0)
39                         valueText:
40                         {
41                                 var secs = Math.round(value);
42                                 var mins = Math.floor(secs/60);
43                                 secs %= 60;
44                                 var hours = Math.floor(mins/60);
45                                 mins %= 60;
46
47                                 var str = "";
48                                 if(hours>0)
49                                 {
50                                         str = hours+":";
51                                         if(mins<10)
52                                                 str += "0";
53                                 }
54
55                                 str += mins+":";
56                                 if(secs<10)
57                                         str += "0";
58
59                                 return str+secs;
60                         }
61
62                         onDownChanged:
63                         {
64                                 if(!down)
65                                         streamControl.position = value;
66                         }
67                 }
68
69                 IconButton
70                 {
71                         id: playPauseButton
72                         anchors.horizontalCenter: parent.horizontalCenter
73                         property string action: (streamControl.playbackState==StreamControl.Playing ? "pause" : "play")
74                         icon.source: "image://theme/icon-l-"+action
75                         onPressed:
76                         {
77                                 if(action=="play")
78                                         streamControl.playbackState = StreamControl.Playing;
79                                 else if(action=="pause")
80                                         streamControl.playbackState = StreamControl.Paused;
81                         }
82                 }
83         }
84
85         StreamControl
86         {
87                 id: streamControl
88                 control: xinemaControl
89                 onPositionChanged:
90                 {
91                         if(!slider.down)
92                                 slider.value = position;
93                 }
94         }
95 }