Skip to content

Commit

Permalink
fix: bottom player image for stations without image but with icyInfo (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier authored Aug 20, 2024
1 parent 62fd095 commit ae27451
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
16 changes: 12 additions & 4 deletions lib/player/view/bottom_player_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import 'package:watch_it/watch_it.dart';
import '../../app/app_model.dart';
import '../../common/data/audio.dart';
import '../../local_audio/view/local_cover.dart';
import '../player_model.dart';
import 'player_fall_back_image.dart';
import 'super_network_image.dart';
import 'player_remote_source_image.dart';

class BottomPlayerImage extends StatelessWidget with WatchItMixin {
const BottomPlayerImage({
Expand Down Expand Up @@ -45,6 +46,8 @@ class BottomPlayerImage extends StatelessWidget with WatchItMixin {
);
}

final mpvMetaData = watchPropertyValue((PlayerModel m) => m.mpvMetaData);

Widget child;

final fallBackImage = PlayerFallBackImage(
Expand All @@ -63,9 +66,14 @@ class BottomPlayerImage extends StatelessWidget with WatchItMixin {
dimension: size,
fallback: fallBackImage,
);
} else if (audio?.albumArtUrl != null || audio?.imageUrl != null) {
child = SuperNetworkImage(
key: ValueKey(audio?.albumArtUrl ?? audio?.imageUrl),
} else if (mpvMetaData?.icyTitle != null ||
audio?.albumArtUrl != null ||
audio?.imageUrl != null) {
child = PlayerRemoteSourceImage(
key: ValueKey(
mpvMetaData?.icyTitle ?? audio?.albumArtUrl ?? audio?.imageUrl,
),
mpvMetaData: mpvMetaData,
height: size,
width: size,
audio: audio,
Expand Down
15 changes: 9 additions & 6 deletions lib/player/view/full_height_player_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../../constants.dart';
import '../../local_audio/view/local_cover.dart';
import '../player_model.dart';
import 'player_fall_back_image.dart';
import 'super_network_image.dart';
import 'player_remote_source_image.dart';

class FullHeightPlayerImage extends StatelessWidget with WatchItMixin {
const FullHeightPlayerImage({
Expand All @@ -23,8 +23,8 @@ class FullHeightPlayerImage extends StatelessWidget with WatchItMixin {
@override
Widget build(BuildContext context) {
final audio = watchPropertyValue((PlayerModel m) => m.audio);
final icyTitle =
watchPropertyValue((PlayerModel m) => m.mpvMetaData?.icyTitle);

final mpvMetaData = watchPropertyValue((PlayerModel m) => m.mpvMetaData);

final fallBackImage = PlayerFallBackImage(
key: const ValueKey(0),
Expand All @@ -45,10 +45,13 @@ class FullHeightPlayerImage extends StatelessWidget with WatchItMixin {
fallback: fallBackImage,
);
} else {
if (audio?.albumArtUrl != null || audio?.imageUrl != null) {
image = SuperNetworkImage(
if (mpvMetaData?.icyTitle != null ||
audio?.albumArtUrl != null ||
audio?.imageUrl != null) {
image = PlayerRemoteSourceImage(
mpvMetaData: mpvMetaData,
key: ValueKey(
(icyTitle ?? '') +
(mpvMetaData?.icyTitle ?? '') +
(audio?.imageUrl ?? '') +
(audio?.albumArtUrl ?? ''),
),
Expand Down
10 changes: 5 additions & 5 deletions lib/player/view/player_fall_back_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ class PlayerFallBackImage extends StatelessWidget {
const PlayerFallBackImage({
super.key,
this.audio,
this.height,
this.width,
required this.height,
required this.width,
});

final Audio? audio;
final double? height;
final double? width;
final double height;
final double width;

@override
Widget build(BuildContext context) {
const iconSize = 40.0;
final iconSize = width * 0.7;
final theme = context.t;
IconData iconData;
if (audio?.audioType == AudioType.radio) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import 'package:flutter/material.dart';
import 'package:watch_it/watch_it.dart';

import '../../common/data/audio.dart';
import '../../common/data/mpv_meta_data.dart';
import '../../common/view/icy_image.dart';
import '../../common/view/safe_network_image.dart';
import '../../extensions/build_context_x.dart';
import '../player_model.dart';

class SuperNetworkImage extends StatelessWidget with WatchItMixin {
const SuperNetworkImage({
class PlayerRemoteSourceImage extends StatelessWidget {
const PlayerRemoteSourceImage({
super.key,
required this.height,
required this.width,
required this.audio,
required this.fit,
required this.fallBackIcon,
required this.errorIcon,
required this.mpvMetaData,
});

final double height;
Expand All @@ -24,11 +24,11 @@ class SuperNetworkImage extends StatelessWidget with WatchItMixin {
final BoxFit? fit;
final Widget fallBackIcon;
final Widget errorIcon;
final MpvMetaData? mpvMetaData;

@override
Widget build(BuildContext context) {
final theme = context.t;
final mpvMetaData = watchPropertyValue((PlayerModel m) => m.mpvMetaData);

final safeNetworkImage = SafeNetworkImage(
url: audio?.imageUrl ?? audio?.albumArtUrl,
Expand Down

0 comments on commit ae27451

Please sign in to comment.