diff --git a/assets/warmer.mp3 b/assets/warmer.mp3 new file mode 100644 index 00000000..638976b2 Binary files /dev/null and b/assets/warmer.mp3 differ diff --git a/lib/components/Player/Player.dart b/lib/components/Player/Player.dart index ff04d3b0..d179afb4 100644 --- a/lib/components/Player/Player.dart +++ b/lib/components/Player/Player.dart @@ -33,6 +33,16 @@ class Player extends HookConsumerWidget { final AsyncSnapshot localStorage = useFuture(future, initialData: null); + useEffect(() { + /// warm up the audio player before playing actual audio + /// It's for resolving unresolved issue related to just_audio's + /// [disposeAllPlayers] method which is throwing + /// [UnimplementedException] in the [PlatformInterface] + /// implementation + player.setAsset("assets/warmer.mp3"); + return null; + }, []); + useEffect(() { if (localStorage.hasData) { _volume.value = localStorage.data?.getDouble(LocalStorageKeys.volume) ?? diff --git a/lib/components/Player/PlayerView.dart b/lib/components/Player/PlayerView.dart index c036bcdb..c6281970 100644 --- a/lib/components/Player/PlayerView.dart +++ b/lib/components/Player/PlayerView.dart @@ -1,5 +1,3 @@ -import 'dart:math'; - import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; @@ -52,25 +50,28 @@ class PlayerView extends HookConsumerWidget { body: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Column( - children: [ - Text( - currentTrack?.name ?? "Not playing", - overflow: TextOverflow.ellipsis, - style: Theme.of(context).textTheme.headline4?.copyWith( - fontWeight: FontWeight.bold, - color: paletteColor.titleTextColor, - ), - ), - artistsToClickableArtists( - currentTrack?.artists ?? [], - mainAxisAlignment: MainAxisAlignment.center, - textStyle: Theme.of(context).textTheme.headline6!.copyWith( - fontWeight: FontWeight.bold, - color: paletteColor.bodyTextColor, - ), - ), - ], + Padding( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + Text( + currentTrack?.name ?? "Not playing", + overflow: TextOverflow.ellipsis, + style: Theme.of(context).textTheme.headline4?.copyWith( + fontWeight: FontWeight.bold, + color: paletteColor.titleTextColor, + ), + ), + artistsToClickableArtists( + currentTrack?.artists ?? [], + mainAxisAlignment: MainAxisAlignment.center, + textStyle: Theme.of(context).textTheme.headline6!.copyWith( + fontWeight: FontWeight.bold, + color: paletteColor.bodyTextColor, + ), + ), + ], + ), ), HookBuilder(builder: (context) { final ticker = useSingleTickerProvider(); diff --git a/lib/provider/Playback.dart b/lib/provider/Playback.dart index a94fc842..4d59d981 100644 --- a/lib/provider/Playback.dart +++ b/lib/provider/Playback.dart @@ -224,7 +224,10 @@ class Playback extends ChangeNotifier { final ytTrack = await toYoutubeTrack(youtube, track); if (setTrackUriById(track.id!, ytTrack.uri!)) { await player - .setAudioSource(AudioSource.uri(Uri.parse(ytTrack.uri!))) + .setAudioSource( + AudioSource.uri(Uri.parse(ytTrack.uri!)), + preload: true, + ) .then((value) { _currentTrack = track; notifyListeners();