Add support for animated GIFs
This commit is contained in:
parent
50a67bb037
commit
b55be4289c
5 changed files with 44 additions and 13 deletions
|
@ -30,6 +30,7 @@ Item {
|
||||||
property int videoFileId;
|
property int videoFileId;
|
||||||
property bool fullscreen : false;
|
property bool fullscreen : false;
|
||||||
property bool onScreen;
|
property bool onScreen;
|
||||||
|
property string videoType : "video";
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
@ -73,19 +74,26 @@ Item {
|
||||||
|
|
||||||
function updateVideoThumbnail() {
|
function updateVideoThumbnail() {
|
||||||
if (typeof videoData === "object") {
|
if (typeof videoData === "object") {
|
||||||
previewFileId = videoData.thumbnail.photo.id;
|
videoType = videoData['@type'];
|
||||||
videoFileId = videoData.video.id;
|
videoFileId = videoData[videoType].id;
|
||||||
if (videoData.thumbnail.photo.local.is_downloading_completed) {
|
if (typeof videoData.thumbnail !== "undefined") {
|
||||||
placeholderImage.source = videoData.thumbnail.photo.local.path;
|
previewFileId = videoData.thumbnail.photo.id;
|
||||||
|
if (videoData.thumbnail.photo.local.is_downloading_completed) {
|
||||||
|
placeholderImage.source = videoData.thumbnail.photo.local.path;
|
||||||
|
} else {
|
||||||
|
tdLibWrapper.downloadFile(previewFileId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
tdLibWrapper.downloadFile(previewFileId);
|
placeholderImage.source = "image://theme/icon-l-video?white";
|
||||||
|
placeholderImage.width = Theme.itemSizeLarge
|
||||||
|
placeholderImage.height = Theme.itemSizeLarge
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePlay() {
|
function handlePlay() {
|
||||||
if (videoData.video.local.is_downloading_completed) {
|
if (videoData[videoType].local.is_downloading_completed) {
|
||||||
videoUrl = videoData.video.local.path;
|
videoUrl = videoData[videoType].local.path;
|
||||||
videoComponentLoader.active = true;
|
videoComponentLoader.active = true;
|
||||||
} else {
|
} else {
|
||||||
videoDownloadBusyIndicator.running = true;
|
videoDownloadBusyIndicator.running = true;
|
||||||
|
@ -104,7 +112,7 @@ Item {
|
||||||
}
|
}
|
||||||
if (fileId === videoFileId) {
|
if (fileId === videoFileId) {
|
||||||
videoDownloadBusyIndicator.running = false;
|
videoDownloadBusyIndicator.running = false;
|
||||||
videoData.video = fileInformation;
|
videoData[videoType] = fileInformation;
|
||||||
videoUrl = fileInformation.local.path;
|
videoUrl = fileInformation.local.path;
|
||||||
if (onScreen) {
|
if (onScreen) {
|
||||||
videoComponentLoader.active = true;
|
videoComponentLoader.active = true;
|
||||||
|
@ -119,6 +127,7 @@ Item {
|
||||||
id: placeholderImage
|
id: placeholderImage
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
|
anchors.centerIn: parent
|
||||||
fillMode: Image.PreserveAspectCrop
|
fillMode: Image.PreserveAspectCrop
|
||||||
visible: status === Image.Ready ? true : false
|
visible: status === Image.Ready ? true : false
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,14 @@ function getMessageText(message, simple) {
|
||||||
if (message.content.caption.text !== "") {
|
if (message.content.caption.text !== "") {
|
||||||
return simple ? qsTr("Video: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
return simple ? qsTr("Video: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||||
} else {
|
} else {
|
||||||
//ENABLE when ready: return simple ? qsTr("shared a video") : "";
|
return simple ? qsTr("shared a video") : "";
|
||||||
qsTr("shared a video");
|
}
|
||||||
|
}
|
||||||
|
if (message.content['@type'] === 'messageAnimation') {
|
||||||
|
if (message.content.caption.text !== "") {
|
||||||
|
return simple ? qsTr("Animation: %1").arg(message.content.caption.text) : enhanceMessageText(message.content.caption)
|
||||||
|
} else {
|
||||||
|
return simple ? qsTr("shared an animation") : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.content['@type'] === 'messageAudio') {
|
if (message.content['@type'] === 'messageAudio') {
|
||||||
|
|
|
@ -442,10 +442,10 @@ Page {
|
||||||
|
|
||||||
VideoPreview {
|
VideoPreview {
|
||||||
id: messageVideoPreview
|
id: messageVideoPreview
|
||||||
videoData: ( display.content['@type'] === "messageVideo" ) ? display.content.video : ""
|
videoData: ( display.content['@type'] === "messageVideo" ) ? display.content.video : ( ( display.content['@type'] === "messageAnimation" ) ? display.content.animation : "")
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: Functions.getVideoHeight(width, display.content.video)
|
height: ( display.content['@type'] === "messageVideo" ) ? Functions.getVideoHeight(width, display.content.video) : Functions.getVideoHeight(width, display.content.animation)
|
||||||
visible: display.content['@type'] === "messageVideo"
|
visible: ( display.content['@type'] === "messageVideo" || display.content['@type'] === "messageAnimation" )
|
||||||
onScreen: chatPage.status === PageStatus.Active
|
onScreen: chatPage.status === PageStatus.Active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,5 +355,13 @@
|
||||||
<source>shared their location</source>
|
<source>shared their location</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Animation: %1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>shared an animation</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
@ -355,5 +355,13 @@
|
||||||
<source>shared their location</source>
|
<source>shared their location</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Animation: %1</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>shared an animation</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
Loading…
Reference in a new issue