on xenial help sign in
Fix subtitle. And use Video Component.
7fea47eYing-Chun Liu
Dash/Movie/MoviePreview.qml+40−25
@@ -15,6 +15,7 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import QtMultimedia 5.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components 0.1
19import ".."
20import ".."
20import "../../Components"
21import "../../Components"
@@ -23,7 +24,7 @@ DashPreview {
23 id: root
24 id: root
24
25
25 property bool ready: previewData ? true : false
26 property bool ready: previewData ? true : false
26− property bool playable: false
27+ property bool playable: previewData.imageSourceUri != null
27 property url url: ready ? previewData.image : ""
28 property url url: ready ? previewData.image : ""
28
29
29 title: root.ready ? previewData.title : ""
30 title: root.ready ? previewData.title : ""
@@ -31,38 +32,52 @@ DashPreview {
31
32
32 onPreviewImageClicked: {
33 onPreviewImageClicked: {
33 if (playable) {
34 if (playable) {
34− shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', root.fileUri);
35+ //shell.activateApplication('/usr/share/applications/mediaplayer-app.desktop', previewData.imageSourceUri);
35 }
36 }
36 }
37 }
37
38
38 // TODO: replace this UbuntuShape with the Video component once that lands
39 // TODO: replace this UbuntuShape with the Video component once that lands
39 // with the player.
40 // with the player.
40− header: UbuntuShape {
41+ header: Rectangle {
41− id: urlLoader
42 anchors.left: parent.left
42 anchors.left: parent.left
43 anchors.right: parent.right
43 anchors.right: parent.right
44− radius: "medium"
45− image: Image {
46− id: previewImage
47− asynchronous: true
48− source: root.url
49− fillMode: Image.PreserveAspectCrop
50− }
51−
52− Image {
53− objectName: "playButton"
54− anchors.centerIn: parent
55− visible: root.playable
56− readonly property bool bigButton: parent.width > units.gu(40)
57− width: bigButton ? units.gu(8) : units.gu(4.5)
58− height: width
44+ height: units.gu(16)
59− source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
45+ color: "black"
60− }
61
46
62− MouseArea {
47+ Video {
63− id: previewImageMouseArea
48+ id: video
64 anchors.fill: parent
49 anchors.fill: parent
50+
51+ source: previewData.imageSourceUri
52+ fillMode: VideoOutput.PreserveAspectCrop
53+
54+ Image {
55+ objectName: "playButton"
56+ anchors.centerIn: parent
57+ visible: root.playable
58+ readonly property bool bigButton: parent.width > units.gu(40)
59+ width: bigButton ? units.gu(8) : units.gu(4.5)
60+ height: width
61+ source: "../graphics/play_button%1%2.png".arg(previewImageMouseArea.pressed ? "_active" : "").arg(bigButton ? "_big" : "")
62+ }
63+
64+ MouseArea {
65+ id: previewImageMouseArea
66+ anchors.fill: parent
67+ onClicked: {
65− onClicked: root.previewImageClicked()
68+ root.previewImageClicked();
69+ if (root.playable) {
70+ if (video.playbackState == MediaPlayer.PlayingState) {
71+ video.pause();
72+ } else if (video.playbackState
73+ == MediaPlayer.PausedState) {
74+ video.play();
75+ } else {
76+ video.play();
77+ }
78+ }
79+ }
80+ }
66 }
81 }
67 }
82 }
68
83
@@ -126,7 +141,7 @@ DashPreview {
126 color: "white"
141 color: "white"
127 horizontalAlignment: Text.AlignRight
142 horizontalAlignment: Text.AlignRight
128 width: parent.firstColWidth
143 width: parent.firstColWidth
129− text: i18n.tr("Directed by:")
144+ text: i18n.tr("Subtitle:")
130 style: Text.Raised
145 style: Text.Raised
131 styleColor: "black"
146 styleColor: "black"
132 }
147 }