diff --git a/lib/provider/playlist_queue_provider.dart b/lib/provider/playlist_queue_provider.dart index 566efeedc..3188fd468 100644 --- a/lib/provider/playlist_queue_provider.dart +++ b/lib/provider/playlist_queue_provider.dart @@ -150,7 +150,7 @@ class PlaylistQueueNotifier extends PersistedStateNotifier { } void configure() async { - audioServices = AudioServices(ref, this); + audioServices = await AudioServices.create(ref, this); audioPlayer.onPlayerComplete.listen((event) async { if (!isLoaded) return; diff --git a/lib/services/audio_services/audio_services.dart b/lib/services/audio_services/audio_services.dart index 3293f02af..31faff98c 100644 --- a/lib/services/audio_services/audio_services.dart +++ b/lib/services/audio_services/audio_services.dart @@ -14,14 +14,24 @@ class AudioServices { final WindowsAudioService? smtc; final LinuxAudioService? mpris; - AudioServices._(this.mobile, this.smtc, this.mpris); + AudioServices(this.mobile, this.smtc, this.mpris); - factory AudioServices(Ref ref, PlaylistQueueNotifier playlistQueueNotifier) { + static Future create( + Ref ref, + PlaylistQueueNotifier playlistQueueNotifier, + ) async { final mobile = DesktopTools.platform.isMobile || DesktopTools.platform.isMacOS - ? MobileAudioService( - playlistQueueNotifier, - ref.read(VolumeProvider.provider.notifier), + ? await AudioService.init( + builder: () => MobileAudioService( + playlistQueueNotifier, + ref.read(VolumeProvider.provider.notifier), + ), + config: const AudioServiceConfig( + androidNotificationChannelId: 'com.krtirtho.Spotube', + androidNotificationChannelName: 'Spotube', + androidNotificationOngoing: true, + ), ) : null; final smtc = DesktopTools.platform.isWindows @@ -31,7 +41,7 @@ class AudioServices { ? LinuxAudioService(ref, playlistQueueNotifier) : null; - return AudioServices._(mobile, smtc, mpris); + return AudioServices(mobile, smtc, mpris); } Future addTrack(Track track) async {