Skip to content

Commit

Permalink
Merge pull request #637 from lamarios/fix/thumbnails-ot-working
Browse files Browse the repository at this point in the history
fix issues with thumbnails
  • Loading branch information
lamarios authored Nov 21, 2024
2 parents 2b1ba04 + bc39537 commit 4097a81
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
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

0 comments on commit 4097a81

Please sign in to comment.