Skip to content

Commit

Permalink
feat: Change default album art for MediaItem
Browse files Browse the repository at this point in the history
fix: Cast error in player provider
  • Loading branch information
ashwinkey04 committed Jan 25, 2022
1 parent a7c7584 commit f16394b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Binary file added assets/images/default_art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions lib/provider/audio_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ Widget getMediaAlbumArt(MediaItem song, Color iconColor) {

Future<File> getDefaultArt() async {
final file =
File('${(await getApplicationDocumentsDirectory()).path}/logo_dark.png');
File('${(await getApplicationDocumentsDirectory()).path}/default_art.png');
if (!(await file.exists())) {
final _byteData = await rootBundle.load('assets/images/logo_dark.png');
final _byteData = await rootBundle.load('assets/images/default_art.png');
await file.writeAsBytes(_byteData.buffer
.asUint8List(_byteData.offsetInBytes, _byteData.lengthInBytes));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/provider/player_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ class AudioPlayerHandler extends BaseAudioHandler {
index = _player.shuffleIndices![index];
}
final oldMediaItem = newQueue[index]!;
final MediaItem? newMediaItem =
oldMediaItem.copyWith(duration: duration!);
final MediaItem newMediaItem =
oldMediaItem.copyWith(duration: duration ?? Duration(minutes: 1));
newQueue[index] = newMediaItem;
queue.add(newQueue as List<MediaItem>);
mediaItem.add(newMediaItem);
Expand All @@ -154,8 +154,8 @@ class AudioPlayerHandler extends BaseAudioHandler {
_player.sequenceStateStream.listen((SequenceState? sequenceState) {
final sequence = sequenceState?.effectiveSequence;
if (sequence == null || sequence.isEmpty) return;
final items = sequence.map((source) => source.tag as MediaItem?);
queue.add(items.toList() as List<MediaItem>);
final items = sequence.map((source) => source.tag as MediaItem);
queue.add(items.toList());
});
}

Expand Down

0 comments on commit f16394b

Please sign in to comment.