Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues with thumbnails #637

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"@shareInvidiousLink": {
"description": "asking user to share invidious link"
},
"ok": "D'accord",
"ok": "D''accord",
"@ok": {
"description": "Ok"
},
Expand Down Expand Up @@ -443,11 +443,11 @@
"@sponsorBlockCategoryMusicOffTopicDescription": {
"description": "Only for use in music videos. This only should be used for sections of music videos that aren't already covered by another category."
},
"appLogsDescription": "Obtenir les registres de ce qui se passe dans l'application, peut être utile pour signaler les problèmes",
"appLogsDescription": "Obtenir les registres de ce qui se passe dans l''application, peut être utile pour signaler les problèmes",
"@appLogsDescription": {
"description": "Description of the app log settings"
},
"appLogs": "Journaux d'application",
"appLogs": "Journaux d''application",
"@appLogs": {
"description": "Title for settings that leads to application logs"
},
Expand All @@ -459,7 +459,7 @@
"@logsCopied": {
"description": "Message to tell user that logs have been copied to the clipboard"
},
"clearSearchHistory": "Effacer l'historique de recherche",
"clearSearchHistory": "Effacer l''historique de recherche",
"@clearSearchHistory": {
"description": "Settings label for clearing search history"
},
Expand Down Expand Up @@ -825,7 +825,7 @@
"@videoAddedToQueue": {
"description": "Pop up message when a video was added at the end of the video queue"
},
"shareLinkWithTimestamp": "Ajouter l'horodatage",
"shareLinkWithTimestamp": "Ajouter l''horodatage",
"@shareLinkWithTimestamp": {
"description": "asking user to share link along with timestamp"
},
Expand Down Expand Up @@ -1403,7 +1403,7 @@
"@cancelSleepTimer": {},
"premieresIn": "Première dans {formattedDuration}",
"@premieresIn": {},
"screenControls": "Contrôles de l'écran",
"screenControls": "Contrôles de l''écran",
"@screenControls": {},
"screenControlsExplanation": "En regardant une vidéo en plein écran, glisser verticalement de la gauche ou de la droite ajustera la luminosité ou le volume respectivement",
"@screenControlsExplanation": {}
Expand Down
5 changes: 4 additions & 1 deletion lib/player/views/components/audio_player.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:clipious/utils/models/image_object.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:clipious/player/views/components/player_controls.dart';
Expand Down Expand Up @@ -49,7 +50,9 @@ class AudioPlayer extends StatelessWidget {
decoration: const BoxDecoration(),
videoId: playerState.video!.videoId,
thumbnailUrl: playerState.video?.deArrowThumbnailUrl ??
playerState.video?.getBestThumbnail()?.url ??
ImageObject.getBestThumbnail(
playerState.video?.videoThumbnails ?? [])
?.url ??
'',
)
: playerState.offlineVideo != null
Expand Down
11 changes: 9 additions & 2 deletions lib/utils/models/image_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@ class ImageObject {
if (images != null && images.isNotEmpty) {
List<ImageObject> imgs = List.from(images);
imgs.sort((a, b) {
return (b.width * b.height).compareTo(a.width * a.height);
final aHasDefault = a.quality?.contains("default") ?? false;
final bHasDefault = b.quality?.contains("default") ?? false;

if (bHasDefault == aHasDefault) {
return (b.width * b.height).compareTo(a.width * a.height);
} else {
return (aHasDefault ? 0 : 1).compareTo(bHasDefault ? 0 : 1);
}
});

return imgs[0];
return imgs.firstOrNull;
} else {
return null;
}
Expand Down
9 changes: 0 additions & 9 deletions lib/videos/models/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ class Video with _$Video implements ShareLinks, IdedVideo {

return link;
}

ImageObject? getBestThumbnail() {
if (videoThumbnails.isNotEmpty) {
return videoThumbnails
.firstWhere((element) => element.quality == 'maxres');
} else {
return null;
}
}
}

/*
Expand Down
4 changes: 3 additions & 1 deletion lib/videos/views/components/inner_view.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:clipious/utils/models/image_object.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
Expand Down Expand Up @@ -54,7 +55,8 @@ class VideoInnerView extends StatelessWidget {
child: VideoThumbnailView(
videoId: video.videoId,
thumbnailUrl: video.deArrowThumbnailUrl ??
video.getBestThumbnail()?.url ??
ImageObject.getBestThumbnail(video.videoThumbnails)
?.url ??
'',
child: phoneLandscape
? const SizedBox.shrink()
Expand Down
4 changes: 3 additions & 1 deletion lib/videos/views/components/inner_view_tablet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:clipious/videos/views/components/play_button.dart';
import '../../../player/states/player.dart';
import '../../../settings/states/settings.dart';
import '../../../utils.dart';
import '../../../utils/models/image_object.dart';
import '../../states/video.dart';
import 'add_to_queue_button.dart';
import 'info.dart';
Expand Down Expand Up @@ -56,7 +57,8 @@ class VideoTabletInnerView extends StatelessWidget {
child: VideoThumbnailView(
videoId: video.videoId,
thumbnailUrl: video.deArrowThumbnailUrl ??
video.getBestThumbnail()?.url ??
ImageObject.getBestThumbnail(video.videoThumbnails)
?.url ??
'',
child: Stack(
alignment: Alignment.center,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: clipious
version: 1.22.2+4065
version: 1.22.3+4066
publish_to: none
description: Client for invidious.
environment:
Expand Down
Loading