Merge lp:~artmello/gallery-app/gallery-app-call_media_player_for_videos into lp:gallery-app

Proposed by Arthur Mello
Status: Merged
Approved by: Ugo Riboni
Approved revision: 1137
Merged at revision: 1138
Proposed branch: lp:~artmello/gallery-app/gallery-app-call_media_player_for_videos
Merge into: lp:gallery-app
Diff against target: 224 lines (+14/-110)
3 files modified
rc/qml/MediaViewer/MediaViewer.qml (+3/-59)
rc/qml/MediaViewer/PopupPhotoViewer.qml (+1/-5)
rc/qml/MediaViewer/SingleMediaViewer.qml (+10/-46)
To merge this branch: bzr merge lp:~artmello/gallery-app/gallery-app-call_media_player_for_videos
Reviewer Review Type Date Requested Status
Ugo Riboni (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+247921@code.launchpad.net

Commit message

Makes gallery-app to call MediaPlayer to play videos instead of playing by itself

Description of the change

Makes gallery-app to call MediaPlayer to play videos instead of playing by itself

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ugo Riboni (uriboni) wrote :

Code looks good and works as expected.

review: Approve
1138. By Arthur Mello

Use the same toolbar for any media type
Do not enable the editor menu for videos

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'rc/qml/MediaViewer/MediaViewer.qml'
2--- rc/qml/MediaViewer/MediaViewer.qml 2015-01-20 17:38:45 +0000
3+++ rc/qml/MediaViewer/MediaViewer.qml 2015-01-30 17:40:10 +0000
4@@ -63,9 +63,7 @@
5 property bool isReady: model != null && model.count > 0 && galleryPhotoViewer.currentItem
6
7 // tooolbar actions for the full view
8- property variant actions: (media && !sharePicker.visible) ? (media.type === MediaSource.Photo ?
9- d.photoActions : d.videoActions)
10- : []
11+ property variant actions: (media && !sharePicker.visible) ? d.mediaActions : []
12
13 property variant backAction: d.backAction
14
15@@ -100,20 +98,6 @@
16 galleryPhotoViewer.goForward();
17 }
18
19- // If the media item is a video, start playing it
20- function playVideo()
21- {
22- if (!galleryPhotoViewer.currentItem)
23- return;
24- if (galleryPhotoViewer.media.type !== MediaSource.Video)
25- return;
26-
27- if (galleryPhotoViewer.currentItem.isPlayingVideo)
28- return;
29-
30- galleryPhotoViewer.currentItem.togglePlayPause();
31- }
32-
33 function setHeaderVisibility(visible)
34 {
35 header.visible = visible;
36@@ -469,12 +453,12 @@
37 Item {
38 id: d
39
40- property list<Action> photoActions: [
41+ property list<Action> mediaActions: [
42 Action {
43 objectName: "editButton"
44 text: i18n.tr("Edit")
45 iconSource: "../../img/edit.png"
46- enabled: galleryPhotoViewer.media.canBeEdited
47+ enabled: galleryPhotoViewer.media.type === MediaSource.Photo && galleryPhotoViewer.media.canBeEdited
48 onTriggered: PopupUtils.open(editPopoverComponent, null);
49 },
50 Action {
51@@ -507,46 +491,6 @@
52 }
53 ]
54
55-
56- property list<Action> videoActions: [
57- Action {
58- text: galleryPhotoViewer.currentItem ?
59- (galleryPhotoViewer.currentItem.isPlayingVideo ?
60- i18n.tr("Pause") : i18n.tr("Play"))
61- : ""
62- iconSource: galleryPhotoViewer.currentItem ?
63- (galleryPhotoViewer.currentItem.isPlayingVideo ?
64- "../../img/icon_pause.png" : "../../img/icon_play.png")
65- : ""
66- onTriggered: galleryPhotoViewer.currentItem.togglePlayPause();
67- },
68- Action {
69- text: i18n.tr("Add to album")
70- iconName: "add"
71- onTriggered: {
72- __albumPicker = PopupUtils.open(Qt.resolvedUrl("../Components/PopupAlbumPicker.qml"),
73- null,
74- {contentHeight: viewerWrapper.__pickerContentHeight});
75- }
76- },
77- Action {
78- text: i18n.tr("Delete")
79- iconName: "delete"
80- onTriggered: {
81- if (album)
82- PopupUtils.open(removeFromAlbumDialog, null);
83- else
84- PopupUtils.open(deleteDialog, null);
85- }
86- },
87- Action {
88- text: i18n.tr("Share")
89- iconName: "share"
90- visible: !APP.desktopMode
91- onTriggered: sharePicker.visible = true;
92- }
93- ]
94-
95 property Action backAction: Action {
96 iconName: "back"
97 onTriggered: {
98
99=== modified file 'rc/qml/MediaViewer/PopupPhotoViewer.qml'
100--- rc/qml/MediaViewer/PopupPhotoViewer.qml 2014-11-06 14:43:21 +0000
101+++ rc/qml/MediaViewer/PopupPhotoViewer.qml 2015-01-30 17:40:10 +0000
102@@ -140,7 +140,6 @@
103 overview.pushPage(popupPhotoViewer);
104 header.visible = false;
105 opened();
106- viewer.playVideo();
107 }
108
109 onTransitionFromPhotoViewerCompleted: {
110@@ -152,10 +151,7 @@
111 id: fadeIn
112
113 target: viewer
114- onStopped: {
115- opened();
116- viewer.playVideo();
117- }
118+ onStopped: opened()
119 }
120
121 FadeOutAnimation {
122
123=== modified file 'rc/qml/MediaViewer/SingleMediaViewer.qml'
124--- rc/qml/MediaViewer/SingleMediaViewer.qml 2015-01-20 17:38:45 +0000
125+++ rc/qml/MediaViewer/SingleMediaViewer.qml 2015-01-30 17:40:10 +0000
126@@ -32,7 +32,6 @@
127 property bool showThumbnail: true
128
129 property bool isVideo: mediaSource.type === MediaSource.Video
130- property bool isPlayingVideo: isVideo && video.isPlaying
131 property bool userInteracting: pinchInProgress || flickable.sizeScale != 1.0
132 property bool fullyZoomed: flickable.sizeScale == zoomPinchArea.maximumZoom
133 property bool fullyUnzoomed: flickable.sizeScale == zoomPinchArea.minimumZoom
134@@ -57,17 +56,8 @@
135 }
136
137 function reset() {
138- if (viewer.isVideo) {
139- if (video.item) {
140- video.item.stop();
141- video.sourceComponent = null;
142- }
143- } else zoomOut()
144- }
145-
146- function togglePlayPause() {
147- if (video.isPlaying) video.pause();
148- else video.play();
149+ if (!viewer.isVideo)
150+ zoomOut()
151 }
152
153 ActivityIndicator {
154@@ -141,7 +131,7 @@
155 height: viewer.maxDimension
156 }
157 fillMode: Image.PreserveAspectFit
158- visible: viewer.showThumbnail && video.status !== Loader.Ready
159+ visible: viewer.showThumbnail
160 opacity: status == Image.Ready ? 1.0 : 0.0
161 Behavior on opacity { UbuntuNumberAnimation {duration: UbuntuAnimation.FastDuration} }
162
163@@ -162,30 +152,6 @@
164 }
165 }
166
167- Loader {
168- id: video
169- anchors.fill: parent
170- visible: viewer.isVideo && video.status == Loader.Ready &&
171- video.item.playbackState !== MediaPlayer.StoppedState
172- onLoaded: {
173- item.source = mediaSource.path;
174- item.play()
175- }
176-
177- property bool isPlaying: item && item.playbackState === MediaPlayer.PlayingState
178- function play() {
179- if (item) {
180- item.play();
181- } else {
182- viewer.showThumbnail = false;
183- sourceComponent = component_video;
184- }
185- }
186- function pause() {
187- if (item) item.pause();
188- }
189- }
190-
191 Icon {
192 width: units.gu(5)
193 height: units.gu(5)
194@@ -193,8 +159,7 @@
195 name: "media-playback-start"
196 color: "white"
197 opacity: 0.8
198- visible: viewer.isVideo &&
199- (!video.item || item.playbackState === MediaPlayer.StoppedState)
200+ visible: viewer.isVideo
201 }
202
203 MouseArea {
204@@ -223,14 +188,13 @@
205 width: units.gu(10)
206 height: units.gu(10)
207 enabled: viewer.isVideo
208- onClicked: viewer.togglePlayPause()
209+ onClicked: {
210+ if (viewer.isVideo) {
211+ var url = mediaSource.path.toString().replace("file://", "video://");
212+ Qt.openUrlExternally(url);
213+ }
214+ }
215 }
216 }
217-
218- Component {
219- id: component_video
220- Video { }
221- }
222 }
223 }
224-

Subscribers

People subscribed via source and target branches