@@ -0,0 +1,332 @@
2+ * Copyright (C) 2015 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+import QtMultimedia 5.0
19+import Ubuntu.Components 1.3
23+ property var sourceData
24+ property string context: ""
25+ property bool fullscreen: false
26+ property list<Action> actions
28+ property alias header: headerContent.item
29+ property alias content: contentLoader.item
30+ property alias footer: footerContent.item
33+ if (fullscreen && parent) {
34+ return parent.height;
36+ console.log(contentLoader.height, fullscreen, parent)
37+ return contentLoader.height
39+ height: implicitHeight
42+ id: orientationHelper
43+ automaticOrientation: false
48+ when: !rotationAction.checked
52+ when: rotationAction.checked
54+ target: orientationHelper
66+ return videoComponent;
75+ width: orientationHelper.width
76+ height: fullscreen ? orientationHelper.height : implicitHeight
77+ fixedHeight: fullscreen
78+ orientation: orientationHelper.state == "portrait" ? Qt.PortraitOrientation : Qt.LandscapeOrientation
81+ var screenshot = root.sourceData["screenshot"];
82+ if (screenshot) return screenshot;
84+ var source = root.sourceData["source"];
86+ if (source.toString().indexOf("file://") === 0) {
87+ return "image://thumbnailer/" + source.toString().substr(7);
93+ mediaPlayer: footer ? footer.mediaPlayer : null
96+ if (mediaPlayer.availability !== MediaPlayer.Available) return;
98+ if (mediaPlayer.playbackState === MediaPlayer.StoppedState) {
100+ } else if (controlHideTimer.running) {
101+ if (mediaPlayer.playbackState === MediaPlayer.PlayingState) {
102+ mediaPlayer.pause();
107+ controlHideTimer.restart();
110+ onPositionChanged: controlHideTimer.restart();
121+ topMargin: -units.gu(6)
128+ anchors.fill: parent
131+ sourceComponent: root.fullscreen ? headerComponent : undefined
136+ MediaServicesHeader {
138+ rotationAction.checked = false;
152+ // If we interact with the bar, reset the hide timer.
155+ anchors.fill: parent
157+ mouse.accepted = false
158+ if (controlHideTimer.running) controlHideTimer.restart()
168+ bottom: parent.bottom
169+ bottomMargin: -units.gu(7)
177+ return videoControlsComponent;
183+ anchors.fill: parent
187+ id: videoControlsComponent
188+ VideoPlayerControls {
191+ viewAction: rotationAction.enabled ? rotationAction : fullscreenAction
192+ userActions: root.actions
194+ mediaPlayer.source: {
195+ var x = root.sourceData["source"];
196+ if (x.toString().indexOf("video://") === 0) {
197+ return x.toString().substr(6);
201+ mediaPlayer.onPlaybackStateChanged: {
202+ controlHideTimer.restart();
206+ target: controlStates
207+ property: "forceControlsShown"
209+ value: (fullscreen && mediaPlayer.playbackState === MediaPlayer.StoppedState) ||
210+ mediaPlayer.playbackState === MediaPlayer.PausedState ||
214+ onInteractingChanged: {
215+ controlHideTimer.restart();
221+ value: controls.mediaPlayer.metaData.title
222+ when: header != null
227+ // If we interact with the bar, reset the hide timer.
230+ anchors.fill: parent
232+ mouse.accepted = false
233+ if (controlHideTimer.running) controlHideTimer.restart()
241+ property bool controlTimerActive: false
242+ property bool forceControlsShown: false
246+ name: "controlsShown"
247+ when: controlStates.forceControlsShown || controlStates.controlTimerActive
249+ target: footerContent
250+ anchors.bottomMargin: 0
254+ target: headerContent
255+ anchors.topMargin: 0
264+ SequentialAnimation {
265+ PropertyAction { target: root; property: "clip"; value: true }
266+ PropertyAction { property: "visible" }
268+ properties: "anchors.bottomMargin,anchors.topMargin"
269+ duration: UbuntuAnimation.FastDuration
271+ PropertyAction { target: root; property: "clip"; value: false }
275+ from: "controlsShown"
276+ SequentialAnimation {
277+ PropertyAction { target: root; property: "clip"; value: true }
279+ properties: "anchors.bottomMargin,anchors.topMargin"
280+ duration: UbuntuAnimation.FastDuration
282+ PropertyAction { property: "visible" }
283+ PropertyAction { target: root; property: "clip"; value: false }
290+ id: controlHideTimer
296+ controlStates.controlTimerActive = true;
299+ onTriggered: controlStates.controlTimerActive = false;
303+ id: fullscreenAction
304+ enabled: rotationAction.enabled === false
305+ iconName: root.fullscreen ? "view-restore" : "view-fullscreen"
308+ root.fullscreen = !root.fullscreen
309+ if (root.fullscreen) {
310+ console.log("fullscreen: fullscreen")
312+ console.log("fullscreen: windowed")
319+ enabled: root.fullscreen === true
320+ iconName: "orientation-lock"
322+ property bool checked: false
326+ console.log("rotation: landscape")
328+ console.log("rotation: portrait")