on xenial help sign in
added copywrite. removed unused code. error handling
commit5ed1c36013e0879260aca0374b0a8724405db4de authorNick Dedekind <nick.dedekind@canonical.com> dateMon 8 Jun 2015, 11:23 (11 years ago) parent126cb55
11 files changed+121−133
qml/Components/MediaServices/MediaServices.qml+28−10 qml/Components/MediaServices/MediaServicesControls.qml−8 qml/Components/MediaServices/MediaServicesHeader.qml−6 qml/Components/MediaServices/VideoPlayer.qml+16−103 qml/Components/MediaServices/VideoPlayerControls.qml+7−3 tests/mocks/QtMultimedia/VideoSurface.qml+16 tests/mocks/QtMultimedia/mediaplayer.cpp+5 tests/mocks/QtMultimedia/mediaplayer.h+16−2 tests/mocks/QtMultimedia/videooutput.cpp+16 tests/mocks/QtMultimedia/videooutput.h+16 tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml+1−1
qml/Components/MediaServices/MediaServices.qml+28−10
@@ -45,29 +45,27 @@ FocusScope {
4545
4646 OrientationHelper {
4747 id: orientationHelper
48− automaticOrientation: false
48+ automaticOrientation: fullscreen && !rotationAction.checked
4949
5050 states: [
5151 State {
5252 name: "portrait"
53− when: !rotationAction.checked
53+ when: !orientationHelper.automaticOrientation && !rotationAction.checked
54+ PropertyChanges {
55+ target: orientationHelper
56+ orientationAngle: 0
57+ }
5458 },
5559 State {
5660 name: "landscape"
57− when: rotationAction.checked
61+ when: !orientationHelper.automaticOrientation && rotationAction.checked
5862 PropertyChanges {
5963 target: orientationHelper
60− orientationAngle: 90
64+ orientationAngle: orientationHelper.orientationAngle == 270 ? 270 : 90
6165 }
6266 }
6367 ]
6468
65− Rectangle {
66− anchors.fill: contentLoader
67− color: "#1B1B1B"
68− opacity: 0.85
69− }
70−
7169 Loader {
7270 id: contentLoader
7371
@@ -79,6 +77,12 @@ FocusScope {
7977 return undefined;
8078 }
8179
80+ Rectangle {
81+ anchors.fill: parent
82+ color: "#1B1B1B"
83+ opacity: 0.85
84+ }
85+
8286 Component {
8387 id: videoComponent
8488 VideoPlayer {
@@ -142,6 +146,13 @@ FocusScope {
142146 anchors.fill: parent
143147 }
144148
149+ Rectangle {
150+ anchors.fill: parent
151+ color: "#1B1B1B"
152+ opacity: 0.85
153+ visible: headerContent.status === Loader.Ready
154+ }
155+
145156 sourceComponent: root.fullscreen ? headerComponent : undefined
146157
147158 Component {
@@ -196,6 +207,13 @@ FocusScope {
196207 anchors.fill: parent
197208 }
198209
210+ Rectangle {
211+ anchors.fill: parent
212+ color: "#1B1B1B"
213+ opacity: 0.85
214+ visible: footerContent.status === Loader.Ready
215+ }
216+
199217 Component {
200218 id: videoControlsComponent
201219 VideoPlayerControls {
qml/Components/MediaServices/MediaServicesControls.qml−8
@@ -3,8 +3,6 @@ import QtQuick.Layouts 1.1
33import QtMultimedia 5.0
44import Ubuntu.Components 1.3
55import Ubuntu.Components.ListItems 1.0 as ListItem
6−import Ubuntu.Components.Themes 1.3
7−import Ubuntu.Components.Popups 1.3
86
97Item {
108 id: root
@@ -17,12 +15,6 @@ Item {
1715 property list<Action> userActions
1816 property Action viewAction
1917
20− Rectangle {
21− anchors.fill: parent
22− color: "#1B1B1B"
23− opacity: 0.85
24− }
25−
2618 RowLayout {
2719 anchors {
2820 left: parent.left
qml/Components/MediaServices/MediaServicesHeader.qml−6
@@ -10,12 +10,6 @@ Item {
1010
1111 signal goPrevious
1212
13− Rectangle {
14− anchors.fill: parent
15− color: "#1B1B1B"
16− opacity: 0.85
17− }
18−
1913 RowLayout {
2014 id: row
2115 anchors {
qml/Components/MediaServices/VideoPlayer.qml+16−103
@@ -76,109 +76,16 @@ Item {
7676
7777 source: mediaPlayer
7878 visible: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
79− }
8079
81−// Loader {
82−// id: shaderLoader
83−// anchors.fill: videoOutput
84−// sourceComponent: fixedHeight ? shaderComponent : undefined
85−
86−// Component {
87−// id: shaderComponent
88−
89−// Item {
90−// ShaderEffect {
91−// id: leftVideo
92−// property variant source: ShaderEffectSource {
93−// sourceItem: videoOutput
94−// hideSource: true
95−// sourceRect: Qt.rect(0, 0, units.gu(2), videoOutput.height)
96−// }
97−// anchors {
98−// top: parent.top
99−// bottom: parent.bottom
100−// left: parent.left
101−// }
102−// width: units.gu(2)
103−// visible: mediaPlayer.playbackState !== MediaPlayer.StoppedState
104−
105−// property real itemOpacity: 0.5
106−
107−// fragmentShader: "
108−// varying highp vec2 qt_TexCoord0;
109−// uniform sampler2D source;
110−// uniform lowp float itemOpacity;
111−// void main(void)
112−// {
113−// highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
114−// sourceColor *= itemOpacity;
115−// gl_FragColor = sourceColor;
116−// }
117−// "
118−// }
119−
120−// ShaderEffect {
121−// id: middleVideo
122−// property variant source: ShaderEffectSource {
123−// sourceItem: videoOutput
124−// hideSource: true
125−// sourceRect: Qt.rect(units.gu(2), 0, videoOutput.width - units.gu(4), videoOutput.height)
126−// }
127−// anchors {
128−// top: parent.top
129−// bottom: parent.bottom
130−// left: leftVideo.right
131−// right: rightVideo.left
132−// }
133−// visible: mediaPlayer.playbackState !== MediaPlayer.StoppedState
134−
135−// property real itemOpacity: 1
136−
137−// fragmentShader: "
138−// varying highp vec2 qt_TexCoord0;
139−// uniform sampler2D source;
140−// uniform lowp float itemOpacity;
141−// void main(void)
142−// {
143−// highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
144−// sourceColor *= itemOpacity;
145−// gl_FragColor = sourceColor;
146−// }
147−// "
148−// }
149−
150−// ShaderEffect {
151−// id: rightVideo
152−// property variant source: ShaderEffectSource {
153−// sourceItem: videoOutput
154−// hideSource: true
155−// sourceRect: Qt.rect(videoOutput.width - units.gu(2), 0, units.gu(2), videoOutput.height)
156−// }
157−// anchors {
158−// top: parent.top
159−// bottom: parent.bottom
160−// right: parent.right
161−// }
162−// width: units.gu(2)
163−// visible: mediaPlayer.playbackState !== MediaPlayer.StoppedState
164−
165−// property real itemOpacity: 0.5
166−
167−// fragmentShader: "
168−// varying highp vec2 qt_TexCoord0;
169−// uniform sampler2D source;
170−// uniform lowp float itemOpacity;
171−// void main(void)
172−// {
173−// highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
174−// sourceColor *= itemOpacity;
175−// gl_FragColor = sourceColor;
176−// }
177−// "
178−// }
179−// }
180−// }
181−// }
80+ Connections {
81+ target: mediaPlayer
82+ onError: {
83+ if (error !== MediaPlayer.NoError) {
84+ errorTimer.restart();
85+ }
86+ }
87+ }
88+ }
18289 }
18390
18491 Rectangle {
@@ -195,9 +102,9 @@ Item {
195102 Behavior on width { UbuntuNumberAnimation {} }
196103
197104 Icon {
198− name: "media-playback-start"
199105 anchors.fill: parent
200106 anchors.margins: units.gu(1)
107+ name: errorTimer.running ? "dialog-warning-symbolic" : "media-playback-start"
201108 color: "#F3F3E7"
202109 }
203110 }
@@ -214,9 +121,15 @@ Item {
214121 MouseArea {
215122 id: contentMouseArea
216123 anchors.fill: content
124+ enabled: !errorTimer.running
217125 hoverEnabled: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
218126
219127 onClicked: root.clicked()
220128 onPositionChanged: root.positionChanged()
221129 }
130+
131+ Timer {
132+ id: errorTimer
133+ interval: 2000
134+ }
222135}
qml/Components/MediaServices/VideoPlayerControls.qml+7−3
@@ -157,8 +157,12 @@ MediaServicesControls {
157157 id: _mediaPlayer
158158 objectName: "mediaPlayer"
159159
160− onPlaybackStateChanged: console.log("PLAYBACK STATE CHANGED", getPlaybackState(playbackState));
161− onStatusChanged: console.log("PLAYER STATUS CHANGED", getPlayerStatus(status));
162− onError: stop()
160+ onError: {
161+ if (error !== MediaPlayer.NoError) {
162+ stop();
163+ }
164+ }
165+// onPlaybackStateChanged: console.log("PLAYBACK STATE CHANGED", getPlaybackState(playbackState));
166+// onStatusChanged: console.log("PLAYER STATUS CHANGED", getPlayerStatus(status));
163167 }
164168}
tests/mocks/QtMultimedia/VideoSurface.qml+16
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
117import QtQuick 2.0
218import Ubuntu.Components 1.3
319import QtMultimedia 5.0
tests/mocks/QtMultimedia/mediaplayer.cpp+5
@@ -119,6 +119,11 @@ int MediaPlayer::duration() const
119119 return 0;
120120}
121121
122+MediaPlayer::Error MediaPlayer::error() const
123+{
124+ return NoError;
125+}
126+
122127QString MediaPlayer::errorString() const
123128{
124129 return QString();
tests/mocks/QtMultimedia/mediaplayer.h+16−2
@@ -33,6 +33,7 @@ class MediaPlayer: public QObject
3333 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
3434 Q_PROPERTY(int position READ position NOTIFY positionChanged)
3535 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
36+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
3637 Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
3738 Q_PROPERTY(AudioRole audioRole READ audioRole WRITE setAudioRole)
3839
@@ -45,6 +46,7 @@ class MediaPlayer: public QObject
4546 Q_ENUMS(AudioRole)
4647 Q_ENUMS(Availability)
4748 Q_ENUMS(Status)
49+ Q_ENUMS(Error)
4850public:
4951 enum PlaybackState {
5052 PlayingState,
@@ -66,8 +68,7 @@ public:
6668 ResourceMissing
6769 };
6870
69− enum Status
70− {
71+ enum Status {
7172 UnknownStatus,
7273 NoMedia,
7374 Loading,
@@ -79,6 +80,15 @@ public:
7980 InvalidMedia
8081 };
8182
83+ enum Error {
84+ NoError,
85+ ResourceError,
86+ FormatError,
87+ NetworkError,
88+ AccessDeniedError,
89+ ServiceMissingError
90+ };
91+
8292 explicit MediaPlayer(QObject *parent = 0);
8393
8494 QUrl source() const;
@@ -90,6 +100,7 @@ public:
90100
91101 int duration() const;
92102
103+ Error error() const;
93104 QString errorString() const;
94105
95106 AudioRole audioRole() const;
@@ -112,10 +123,13 @@ Q_SIGNALS:
112123 void positionChanged(int position);
113124 void durationChanged(int duration);
114125 void seekableChanged(bool seekable);
126+ void errorChanged(Error error);
115127 void errorStringChanged(const QString &errorString);
116128 void availabilityChanged(Availability availability);
117129 void statusChanged();
118130
131+ void error(Error error, const QString &errorString);
132+
119133private Q_SLOTS:
120134 void timerEvent();
121135
tests/mocks/QtMultimedia/videooutput.cpp+16
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
117#include "videooutput.h"
218#include "mediaplayer.h"
319
tests/mocks/QtMultimedia/videooutput.h+16
@@ -1,3 +1,19 @@
1+/*
2+ * Copyright (C) 2015 Canonical, Ltd.
3+ *
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.
7+ *
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.
12+ *
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/>.
15+ */
16+
117#ifndef VIDEOOUTPUT_H
218#define VIDEOOUTPUT_H
319
tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml+1−1
@@ -57,7 +57,7 @@ Rectangle {
5757 right: controls.left
5858 }
5959
60− Rectangle {
60+ Item {
6161 anchors.fill: parent
6262 anchors.margins: units.gu(2)
6363