]> git.tdb.fi Git - xinema.git/blob - remote/qml/pages/PlaybackPage.qml
bf1d976c0b382eccc18a14dbc844ea9dac388633
[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 import "../components"
5
6 Page
7 {
8         id: page
9
10         Column
11         {
12                 width: parent.width
13                 spacing: Theme.paddingLarge
14
15                 PageHeader
16                 {
17                         title: qsTr("Playback")
18                 }
19
20                 Label
21                 {
22                         text: streamControl.title
23                         anchors
24                         {
25                                 left: parent.left
26                                 right: parent.right
27                                 margins: Theme.horizontalPageMargin
28                         }
29                         horizontalAlignment: Text.AlignHCenter
30                         wrapMode: Text.WordWrap
31                 }
32
33                 Slider
34                 {
35                         id: slider
36                         width: parent.width
37
38                         minimumValue: 0.0
39                         maximumValue: Math.max(streamControl.duration, 1.0)
40                         valueText:
41                         {
42                                 var secs = Math.round(value);
43                                 var mins = Math.floor(secs/60);
44                                 secs %= 60;
45                                 var hours = Math.floor(mins/60);
46                                 mins %= 60;
47
48                                 var str = "";
49                                 if(hours>0)
50                                 {
51                                         str = hours+":";
52                                         if(mins<10)
53                                                 str += "0";
54                                 }
55
56                                 str += mins+":";
57                                 if(secs<10)
58                                         str += "0";
59
60                                 return str+secs;
61                         }
62
63                         onDownChanged:
64                         {
65                                 if(!down)
66                                         streamControl.position = value;
67                         }
68                 }
69
70                 IconButton
71                 {
72                         id: playPauseButton
73                         anchors.horizontalCenter: parent.horizontalCenter
74                         property string action: (streamControl.playbackState==StreamControl.Playing ? "pause" : "play")
75                         icon.source: "image://theme/icon-l-"+action
76                         onPressed:
77                         {
78                                 if(action=="play")
79                                         streamControl.playbackState = StreamControl.Playing;
80                                 else if(action=="pause")
81                                         streamControl.playbackState = StreamControl.Paused;
82                         }
83                 }
84
85                 ChannelSelect
86                 {
87                         id: audioSelect
88                         label: "Audio"
89                         channels: streamControl.audioChannels
90                         onCurrentChannelChanged: streamControl.currentAudioChannel = currentChannel
91                 }
92
93                 ChannelSelect
94                 {
95                         id: spuSelect
96                         label: "Subtitles"
97                         channels: streamControl.spuChannels
98                         onCurrentChannelChanged: streamControl.currentSpuChannel = currentChannel
99                 }
100         }
101
102         StreamControl
103         {
104                 id: streamControl
105                 control: xinemaControl
106                 onPositionChanged:
107                 {
108                         if(!slider.down)
109                                 slider.value = position;
110                 }
111                 onCurrentAudioChannelChanged: audioSelect.currentChannel = streamControl.currentAudioChannel;
112                 onCurrentSpuChannelChanged: spuSelect.currentChannel = streamControl.currentSpuChannel;
113         }
114 }