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