Skip to content

Commit

Permalink
Change how using videoloader is decided and use it to all videos, add…
Browse files Browse the repository at this point in the history
… specific thumbnail and scale videos to screen.

Fixes #28
  • Loading branch information
walokra committed Nov 15, 2021
1 parent 01f7053 commit 6b3a151
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
5 changes: 4 additions & 1 deletion qml/components/imgur.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,12 @@ function fillAlbumImagesModel(output, model) {
gifv: (output.gifv) ? output.gifv : "",
mp4: (output.mp4) ? output.mp4 : "",
webm: (output.webm) ? output.webm : "",
looping: (output.looping) ? output.looping : false
looping: (output.looping) ? output.looping : false,
thumbnail: IMGUR_IMG_URL + output.id+"l.jpg" // s=90x90, b=160x16; t=160x160, m=320x320,l=640x640, h=1024x1024 (aspect)
};

//console.debug(JSON.stringify(imageData));

model.push(imageData);
}

Expand Down
23 changes: 8 additions & 15 deletions qml/pages/GalleryContentDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,17 @@ Item {
// webm = video/x-vp8, video/x-h264
// "No decoder available for type 'video/x-vp8'
function activateLoader() {
//console.debug("link=", link, "; size=",size, "type=",type, "; mp4=",mp4, "; gifv=",gifv, "; webm=",webm);
//console.debug("vWidth=" + vWidth + "; vHeight="+vHeight)
//console.debug("link=",link, "; size=",size, "type=",type, "; animated=",animated, "; mp4=",mp4, "; gifv=",gifv, "; thumbnail=",thumbnail);
imageLoader.active = false;
videoLoader.active = false;

if (animated === false) {
if (!animated) {
imageLoader.active = true;
} else if ((type === "image/gif" || type === "video/mp4" || (mp4 !== "")) && settings.useVideoLoader === true) {
// If gifv video is under maxGifSize, use animatedImage (smoother)
if (size && size.indexOf("MiB") > -1) {
var sizeNo = size.replace(" MiB", "");
if (parseInt(sizeNo) > settings.maxGifSize) {
videoLoader.active = true;
}
}
}
if (imageLoader.active == false && videoLoader.active == false) {
} else if (type === "video/mp4") {
videoLoader.active = true;
} else if (type === "image/gif") {
imageLoader.active = true;
} else {
imageLoader.active = true;
}
}
Expand Down Expand Up @@ -67,7 +61,6 @@ Item {
height: imageColumn.height;
backgroundSize: parent.width / 5;

// background: Item { }
background: Item {
id: drawerContextMenu;
anchors.left: parent.left; anchors.right: parent.right;
Expand Down Expand Up @@ -106,7 +99,7 @@ Item {
asynchronous: true;

width: Screen.width;
height: (active) ? vHeight : 0;
height: (active) ? Math.min(vHeight * (Screen.width / vWidth), Screen.height) : 0;

anchors.horizontalCenter: parent.horizontalCenter;

Expand Down
12 changes: 6 additions & 6 deletions qml/pages/VideoComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Component {
id: root;
anchors { left: parent.left; right: parent.right; }

height: Math.max(((video) ? video.height : 0), image.height, 3*loadingVideoIndicator.height);
height: Math.max(vHeight * (Screen.width / vWidth), 3*loadingVideoIndicator.height);
width: Screen.width;

property int start_x;
Expand All @@ -35,23 +35,23 @@ Component {
}
}

Image {
Image {
id: image;
asynchronous: true;

fillMode: Image.PreserveAspectFit;
source: link_original;
source: thumbnail;
width: parent.width;
height: sourceSize.height * (Screen.width / sourceSize.width);
height: vHeight * (Screen.width / vWidth);

visible: (mediaPlayer) ? mediaPlayer.playbackState == MediaPlayer.StoppedState : true;
}

VideoOutput {
id: video;

width: image.width;
height: image.height;
width: Screen.width;
height: Math.min(vHeight * (Screen.width / vWidth), Screen.height)

fillMode: VideoOutput.PreserveAspectFit;

Expand Down

0 comments on commit 6b3a151

Please sign in to comment.