2 * Copyright (C) 2016 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
20 import Ubuntu.Thumbnailer 0.1
21 import "../../Components"
26 property alias screenshot: image.source
27 property alias mediaPlayer: videoOutput.source
28 property int orientation: Qt.PortraitOrientation
29 property bool fixedHeight: false
30 property var maximumEmbeddedHeight
32 property alias playButtonBackgroundColor: playButton.color
33 property alias playButtonIconColor: playButtonIcon.color
36 if (parent && orientation === Qt.LandscapeOrientation) {
39 return content.height;
43 signal positionChanged
50 verticalCenter: parent.verticalCenter
53 if (root.orientation === Qt.LandscapeOrientation || fixedHeight) {
56 var proposedHeight = videoOutput.height;
57 if (maximumEmbeddedHeight !== undefined && maximumEmbeddedHeight < proposedHeight) {
58 return maximumEmbeddedHeight;
60 return proposedHeight;
62 clip: image.height > videoOutput.height
66 objectName: "screenshot"
70 verticalCenter: parent.verticalCenter
73 lastScaledDimension: playButton.height + units.gu(2)
74 initialHeight: lastScaledDimension
77 visible: !mediaPlayer || mediaPlayer.playbackState === MediaPlayer.StoppedState
82 anchors.centerIn: parent
89 var proposedHeight = mediaPlayer && mediaPlayer.metaData.resolution !== undefined ?
90 (mediaPlayer.metaData.resolution.height / mediaPlayer.metaData.resolution.width) * width :
92 if (maximumEmbeddedHeight !== undefined && maximumEmbeddedHeight < proposedHeight) {
93 return maximumEmbeddedHeight;
95 return proposedHeight;
99 visible: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
104 if (error !== MediaPlayer.NoError) {
105 errorTimer.restart();
114 readonly property bool bigButton: parent.width > units.gu(40)
115 anchors.centerIn: content
116 width: bigButton ? units.gu(10) : units.gu(8)
118 visible: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.PlayingState || false
122 Behavior on width { UbuntuNumberAnimation {} }
127 anchors.margins: units.gu(1)
128 name: errorTimer.running ? "dialog-warning-symbolic" : "media-playback-start"
133 anchors.centerIn: content
135 if (!mediaPlayer) return false;
136 return mediaPlayer.status === MediaPlayer.Stalled ||
137 (mediaPlayer.playbackState === MediaPlayer.PlayingState && mediaPlayer.status === MediaPlayer.Loading);
143 anchors.fill: content
144 enabled: !errorTimer.running
145 hoverEnabled: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
147 onClicked: root.clicked()
148 onPositionChanged: root.positionChanged()