]> git.tdb.fi Git - xinema.git/blob - remote/qml/pages/PlaybackPage.qml
Display the various bits of info only if they are available
[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                 Column
34                 {
35                         width: parent.width
36                         spacing: Theme.paddingSmall
37
38                         StreamInfo
39                         {
40                                 visible: streamControl.videoSize.width && streamControl.videoSize.height
41                                 property string size: streamControl.videoSize.width+"×"+streamControl.videoSize.height
42                                 property string fps: " @ "+streamControl.framerate.toFixed(2)+"fps"
43                                 text: (streamControl.framerate ? size+fps : size)
44                         }
45
46                         StreamInfo
47                         {
48                                 visible: streamControl.videoCodec
49                                 text: streamControl.videoCodec
50                         }
51
52                         StreamInfo
53                         {
54                                 visible: streamControl.audioCodec
55                                 text: streamControl.audioCodec
56                         }
57                 }
58
59                 Slider
60                 {
61                         id: slider
62                         width: parent.width
63
64                         minimumValue: 0.0
65                         maximumValue: Math.max(streamControl.duration, 1.0)
66                         valueText:
67                         {
68                                 var secs = Math.round(value);
69                                 var mins = Math.floor(secs/60);
70                                 secs %= 60;
71                                 var hours = Math.floor(mins/60);
72                                 mins %= 60;
73
74                                 var str = "";
75                                 if(hours>0)
76                                 {
77                                         str = hours+":";
78                                         if(mins<10)
79                                                 str += "0";
80                                 }
81
82                                 str += mins+":";
83                                 if(secs<10)
84                                         str += "0";
85
86                                 return str+secs;
87                         }
88
89                         onDownChanged:
90                         {
91                                 if(!down)
92                                         streamControl.position = value;
93                         }
94                 }
95
96                 IconButton
97                 {
98                         id: playPauseButton
99                         anchors.horizontalCenter: parent.horizontalCenter
100                         property string action: (streamControl.playbackState==StreamControl.Playing ? "pause" : "play")
101                         icon.source: "image://theme/icon-l-"+action
102                         onPressed:
103                         {
104                                 if(action=="play")
105                                         streamControl.playbackState = StreamControl.Playing;
106                                 else if(action=="pause")
107                                         streamControl.playbackState = StreamControl.Paused;
108                         }
109                 }
110         }
111
112         Column
113         {
114                 width: parent.width
115                 spacing: Theme.paddingLarge
116                 anchors.bottom: page.bottom
117                 anchors.bottomMargin: 2*Theme.paddingLarge
118
119                 ChannelSelect
120                 {
121                         id: audioSelect
122                         label: "Audio"
123                         channels: streamControl.audioChannels
124                         onCurrentChannelChanged: streamControl.currentAudioChannel = currentChannel
125                 }
126
127                 ChannelSelect
128                 {
129                         id: spuSelect
130                         label: "Subtitles"
131                         channels: streamControl.spuChannels
132                         onCurrentChannelChanged: streamControl.currentSpuChannel = currentChannel
133                 }
134         }
135
136         StreamControl
137         {
138                 id: streamControl
139                 control: xinemaControl
140                 onPositionChanged:
141                 {
142                         if(!slider.down)
143                                 slider.value = position;
144                 }
145                 onCurrentAudioChannelChanged: audioSelect.currentChannel = streamControl.currentAudioChannel;
146                 onCurrentSpuChannelChanged: spuSelect.currentChannel = streamControl.currentSpuChannel;
147         }
148 }