on xenial help sign in
added copywrite. removed unused code. error handling
5ed1c36Nick Dedekind
qml/Components/MediaServices/MediaServices.qml+28−10
@@ -45,29 +45,27 @@ FocusScope {
45
45
46 OrientationHelper {
46 OrientationHelper {
47 id: orientationHelper
47 id: orientationHelper
48− automaticOrientation: false
48+ automaticOrientation: fullscreen && !rotationAction.checked
49
49
50 states: [
50 states: [
51 State {
51 State {
52 name: "portrait"
52 name: "portrait"
53− when: !rotationAction.checked
53+ when: !orientationHelper.automaticOrientation && !rotationAction.checked
54+ PropertyChanges {
55+ target: orientationHelper
56+ orientationAngle: 0
57+ }
54 },
58 },
55 State {
59 State {
56 name: "landscape"
60 name: "landscape"
57− when: rotationAction.checked
61+ when: !orientationHelper.automaticOrientation && rotationAction.checked
58 PropertyChanges {
62 PropertyChanges {
59 target: orientationHelper
63 target: orientationHelper
60− orientationAngle: 90
64+ orientationAngle: orientationHelper.orientationAngle == 270 ? 270 : 90
61 }
65 }
62 }
66 }
63 ]
67 ]
64
68
65− Rectangle {
66− anchors.fill: contentLoader
67− color: "#1B1B1B"
68− opacity: 0.85
69− }
70−
71 Loader {
69 Loader {
72 id: contentLoader
70 id: contentLoader
73
71
@@ -79,6 +77,12 @@ FocusScope {
79 return undefined;
77 return undefined;
80 }
78 }
81
79
80+ Rectangle {
81+ anchors.fill: parent
82+ color: "#1B1B1B"
83+ opacity: 0.85
84+ }
85+
82 Component {
86 Component {
83 id: videoComponent
87 id: videoComponent
84 VideoPlayer {
88 VideoPlayer {
@@ -142,6 +146,13 @@ FocusScope {
142 anchors.fill: parent
146 anchors.fill: parent
143 }
147 }
144
148
149+ Rectangle {
150+ anchors.fill: parent
151+ color: "#1B1B1B"
152+ opacity: 0.85
153+ visible: headerContent.status === Loader.Ready
154+ }
155+
145 sourceComponent: root.fullscreen ? headerComponent : undefined
156 sourceComponent: root.fullscreen ? headerComponent : undefined
146
157
147 Component {
158 Component {
@@ -196,6 +207,13 @@ FocusScope {
196 anchors.fill: parent
207 anchors.fill: parent
197 }
208 }
198
209
210+ Rectangle {
211+ anchors.fill: parent
212+ color: "#1B1B1B"
213+ opacity: 0.85
214+ visible: footerContent.status === Loader.Ready
215+ }
216+
199 Component {
217 Component {
200 id: videoControlsComponent
218 id: videoControlsComponent
201 VideoPlayerControls {
219 VideoPlayerControls {
qml/Components/MediaServices/MediaServicesControls.qml−8
@@ -3,8 +3,6 @@ import QtQuick.Layouts 1.1
3import QtMultimedia 5.0
3import QtMultimedia 5.0
4import Ubuntu.Components 1.3
4import Ubuntu.Components 1.3
5import Ubuntu.Components.ListItems 1.0 as ListItem
5import Ubuntu.Components.ListItems 1.0 as ListItem
6−import Ubuntu.Components.Themes 1.3
7−import Ubuntu.Components.Popups 1.3
8
6
9Item {
7Item {
10 id: root
8 id: root
@@ -17,12 +15,6 @@ Item {
17 property list<Action> userActions
15 property list<Action> userActions
18 property Action viewAction
16 property Action viewAction
19
17
20− Rectangle {
21− anchors.fill: parent
22− color: "#1B1B1B"
23− opacity: 0.85
24− }
25−
26 RowLayout {
18 RowLayout {
27 anchors {
19 anchors {
28 left: parent.left
20 left: parent.left
qml/Components/MediaServices/MediaServicesHeader.qml−6
@@ -10,12 +10,6 @@ Item {
10
10
11 signal goPrevious
11 signal goPrevious
12
12
13− Rectangle {
14− anchors.fill: parent
15− color: "#1B1B1B"
16− opacity: 0.85
17− }
18−
19 RowLayout {
13 RowLayout {
20 id: row
14 id: row
21 anchors {
15 anchors {
qml/Components/MediaServices/VideoPlayer.qml+16−103
@@ -76,109 +76,16 @@ Item {
76
76
77 source: mediaPlayer
77 source: mediaPlayer
78 visible: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
78 visible: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
79− }
80
79
81−// Loader {
80+ Connections {
82−// id: shaderLoader
81+ target: mediaPlayer
83−// anchors.fill: videoOutput
82+ onError: {
84−// sourceComponent: fixedHeight ? shaderComponent : undefined
83+ if (error !== MediaPlayer.NoError) {
85−
84+ errorTimer.restart();
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−// }
85+ }
179−// }
86+ }
180−// }
87+ }
181−// }
88+ }
182 }
89 }
183
90
184 Rectangle {
91 Rectangle {
@@ -195,9 +102,9 @@ Item {
195 Behavior on width { UbuntuNumberAnimation {} }
102 Behavior on width { UbuntuNumberAnimation {} }
196
103
197 Icon {
104 Icon {
198− name: "media-playback-start"
199 anchors.fill: parent
105 anchors.fill: parent
200 anchors.margins: units.gu(1)
106 anchors.margins: units.gu(1)
107+ name: errorTimer.running ? "dialog-warning-symbolic" : "media-playback-start"
201 color: "#F3F3E7"
108 color: "#F3F3E7"
202 }
109 }
203 }
110 }
@@ -214,9 +121,15 @@ Item {
214 MouseArea {
121 MouseArea {
215 id: contentMouseArea
122 id: contentMouseArea
216 anchors.fill: content
123 anchors.fill: content
124+ enabled: !errorTimer.running
217 hoverEnabled: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
125 hoverEnabled: mediaPlayer && mediaPlayer.playbackState !== MediaPlayer.StoppedState || false
218
126
219 onClicked: root.clicked()
127 onClicked: root.clicked()
220 onPositionChanged: root.positionChanged()
128 onPositionChanged: root.positionChanged()
221 }
129 }
130+
131+ Timer {
132+ id: errorTimer
133+ interval: 2000
134+ }
222}
135}
qml/Components/MediaServices/VideoPlayerControls.qml+7−3
@@ -157,8 +157,12 @@ MediaServicesControls {
157 id: _mediaPlayer
157 id: _mediaPlayer
158 objectName: "mediaPlayer"
158 objectName: "mediaPlayer"
159
159
160+ onError: {
161+ if (error !== MediaPlayer.NoError) {
162+ stop();
163+ }
164+ }
160− onPlaybackStateChanged: console.log("PLAYBACK STATE CHANGED", getPlaybackState(playbackState));
165+// onPlaybackStateChanged: console.log("PLAYBACK STATE CHANGED", getPlaybackState(playbackState));
161− onStatusChanged: console.log("PLAYER STATUS CHANGED", getPlayerStatus(status));
166+// onStatusChanged: console.log("PLAYER STATUS CHANGED", getPlayerStatus(status));
162− onError: stop()
163 }
167 }
164}
168}
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+
1import QtQuick 2.0
17import QtQuick 2.0
2import Ubuntu.Components 1.3
18import Ubuntu.Components 1.3
3import QtMultimedia 5.0
19import QtMultimedia 5.0
tests/mocks/QtMultimedia/mediaplayer.cpp+5
@@ -119,6 +119,11 @@ int MediaPlayer::duration() const
119 return 0;
119 return 0;
120}
120}
121
121
122+MediaPlayer::Error MediaPlayer::error() const
123+{
124+ return NoError;
125+}
126+
122QString MediaPlayer::errorString() const
127QString MediaPlayer::errorString() const
123{
128{
124 return QString();
129 return QString();
tests/mocks/QtMultimedia/mediaplayer.h+16−2
@@ -33,6 +33,7 @@ class MediaPlayer: public QObject
33 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
33 Q_PROPERTY(PlaybackState playbackState READ playbackState NOTIFY playbackStateChanged)
34 Q_PROPERTY(int position READ position NOTIFY positionChanged)
34 Q_PROPERTY(int position READ position NOTIFY positionChanged)
35 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
35 Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
36+ Q_PROPERTY(Error error READ error NOTIFY errorChanged)
36 Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
37 Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged)
37 Q_PROPERTY(AudioRole audioRole READ audioRole WRITE setAudioRole)
38 Q_PROPERTY(AudioRole audioRole READ audioRole WRITE setAudioRole)
38
39
@@ -45,6 +46,7 @@ class MediaPlayer: public QObject
45 Q_ENUMS(AudioRole)
46 Q_ENUMS(AudioRole)
46 Q_ENUMS(Availability)
47 Q_ENUMS(Availability)
47 Q_ENUMS(Status)
48 Q_ENUMS(Status)
49+ Q_ENUMS(Error)
48public:
50public:
49 enum PlaybackState {
51 enum PlaybackState {
50 PlayingState,
52 PlayingState,
@@ -66,8 +68,7 @@ public:
66 ResourceMissing
68 ResourceMissing
67 };
69 };
68
70
69− enum Status
71+ enum Status {
70− {
71 UnknownStatus,
72 UnknownStatus,
72 NoMedia,
73 NoMedia,
73 Loading,
74 Loading,
@@ -79,6 +80,15 @@ public:
79 InvalidMedia
80 InvalidMedia
80 };
81 };
81
82
83+ enum Error {
84+ NoError,
85+ ResourceError,
86+ FormatError,
87+ NetworkError,
88+ AccessDeniedError,
89+ ServiceMissingError
90+ };
91+
82 explicit MediaPlayer(QObject *parent = 0);
92 explicit MediaPlayer(QObject *parent = 0);
83
93
84 QUrl source() const;
94 QUrl source() const;
@@ -90,6 +100,7 @@ public:
90
100
91 int duration() const;
101 int duration() const;
92
102
103+ Error error() const;
93 QString errorString() const;
104 QString errorString() const;
94
105
95 AudioRole audioRole() const;
106 AudioRole audioRole() const;
@@ -112,10 +123,13 @@ Q_SIGNALS:
112 void positionChanged(int position);
123 void positionChanged(int position);
113 void durationChanged(int duration);
124 void durationChanged(int duration);
114 void seekableChanged(bool seekable);
125 void seekableChanged(bool seekable);
126+ void errorChanged(Error error);
115 void errorStringChanged(const QString &errorString);
127 void errorStringChanged(const QString &errorString);
116 void availabilityChanged(Availability availability);
128 void availabilityChanged(Availability availability);
117 void statusChanged();
129 void statusChanged();
118
130
131+ void error(Error error, const QString &errorString);
132+
119private Q_SLOTS:
133private Q_SLOTS:
120 void timerEvent();
134 void timerEvent();
121
135
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+
1#include "videooutput.h"
17#include "videooutput.h"
2#include "mediaplayer.h"
18#include "mediaplayer.h"
3
19
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+
1#ifndef VIDEOOUTPUT_H
17#ifndef VIDEOOUTPUT_H
2#define VIDEOOUTPUT_H
18#define VIDEOOUTPUT_H
3
19
tests/qmltests/Dash/Previews/tst_PreviewInlineVideo.qml+1−1
@@ -57,7 +57,7 @@ Rectangle {
57 right: controls.left
57 right: controls.left
58 }
58 }
59
59
60− Rectangle {
60+ Item {
61 anchors.fill: parent
61 anchors.fill: parent
62 anchors.margins: units.gu(2)
62 anchors.margins: units.gu(2)
63
63