Fix network image error

This commit is contained in:
gianlucaparadise 2021-12-21 06:58:30 +01:00
parent 5132ca9749
commit d066611846

View file

@ -114,6 +114,8 @@ class _ExpandedControlsState extends State<ExpandedControls> {
int durationMs, int durationMs,
int whenSkippableMs, int whenSkippableMs,
) { ) {
debugPrint(
"adBreakId: $adBreakId adBreakClipId: $adBreakClipId progress: $progressMs duration: $durationMs whenSkip: $whenSkippableMs");
widget.controller.updateProgress(progressMs, durationMs); widget.controller.updateProgress(progressMs, durationMs);
} }
@ -165,7 +167,12 @@ class _ExpandedControlsState extends State<ExpandedControls> {
} }
DecorationImage? _getBackgroundImage(MediaInfo? mediaInfo) { DecorationImage? _getBackgroundImage(MediaInfo? mediaInfo) {
final imgUrl = mediaInfo?.mediaMetadata?.webImages?.first?.url; final webImages = mediaInfo?.mediaMetadata?.webImages;
if (webImages?.isEmpty == true) {
return null;
}
final imgUrl = webImages?.first?.url;
if (imgUrl == null || imgUrl.isEmpty) { if (imgUrl == null || imgUrl.isEmpty) {
return null; return null;
} }
@ -173,6 +180,8 @@ class _ExpandedControlsState extends State<ExpandedControls> {
return DecorationImage( return DecorationImage(
image: NetworkImage(imgUrl), image: NetworkImage(imgUrl),
fit: BoxFit.cover, fit: BoxFit.cover,
onError: (exception, stackTrace) => debugPrint(
"ExpandedControls: error while retrieving image with url: $imgUrl"),
); );
} }