diff --git a/lib/service/audio_service.dart b/lib/service/audio_service.dart index 071f8c1..00232be 100644 --- a/lib/service/audio_service.dart +++ b/lib/service/audio_service.dart @@ -48,6 +48,8 @@ class AudioPlayerHandler extends BaseAudioHandler with QueueHandler, SeekHandler int? _prevAudioSession; bool _equalizerOpen = false; + final AndroidAuto _androidAuto = AndroidAuto(); // Create an instance of AndroidAuto + // for some reason, dart can decide not to respect the 'await' due to weird task sceduling ... final Completer _playerInitializedCompleter = Completer(); late AudioPlayer _player; @@ -222,8 +224,6 @@ class AudioPlayerHandler extends BaseAudioHandler with QueueHandler, SeekHandler } } - final AndroidAuto _androidAuto = AndroidAuto(); // Create an instance of AndroidAuto - @override Future playFromMediaId(String mediaId, [Map? extras]) async { // Check if the mediaId is for Android Auto @@ -384,8 +384,7 @@ class AudioPlayerHandler extends BaseAudioHandler with QueueHandler, SeekHandler Map? options, ]) async { //Android audio callback - AndroidAuto androidAuto = AndroidAuto(); - return androidAuto.getScreen(parentMediaId); + return _androidAuto.getScreen(parentMediaId); } //----------------------------------------------