diff --git a/lib/services/windows_audio_service.dart b/lib/services/windows_audio_service.dart index 305eb19d6..cc87b59f3 100644 --- a/lib/services/windows_audio_service.dart +++ b/lib/services/windows_audio_service.dart @@ -15,7 +15,8 @@ class WindowsAudioService { final subscriptions = []; - WindowsAudioService(this.ref, this.playlistNotifier) : smtc = SMTCWindows() { + WindowsAudioService(this.ref, this.playlistNotifier) + : smtc = SMTCWindows(enabled: false) { smtc.setPlaybackStatus(PlaybackStatus.Stopped); final buttonStream = smtc.buttonPressStream.listen((event) { switch (event) { @@ -50,9 +51,11 @@ class WindowsAudioService { break; case PlayerState.stopped: await smtc.setPlaybackStatus(PlaybackStatus.Stopped); + await smtc.disableSmtc(); break; case PlayerState.completed: await smtc.setPlaybackStatus(PlaybackStatus.Changing); + await smtc.disableSmtc(); break; default: break; @@ -77,12 +80,14 @@ class WindowsAudioService { } Future addTrack(Track track) async { + if (!smtc.enabled) { + await smtc.enableSmtc(); + } await smtc.updateMetadata(MusicMetadata( title: track.name!, albumArtist: track.artists?.first.name ?? "Unknown", artist: TypeConversionUtils.artists_X_String(track.artists ?? []), album: track.album?.name ?? "Unknown", - trackNumber: track.trackNumber ?? 0, thumbnail: TypeConversionUtils.image_X_UrlString( track.album?.images ?? [], placeholder: ImagePlaceholder.albumArt, @@ -91,6 +96,7 @@ class WindowsAudioService { } void dispose() { + smtc.disableSmtc(); smtc.dispose(); for (var element in subscriptions) { element.cancel(); diff --git a/pubspec.lock b/pubspec.lock index f7b157731..f798638f6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -610,9 +610,11 @@ packages: flutter_desktop_tools: dependency: "direct main" description: - path: "../flutter_desktop_tools" - relative: true - source: path + path: "." + ref: "2fca12d1767dad41421e846383d99ac26e29d202" + resolved-ref: "2fca12d1767dad41421e846383d99ac26e29d202" + url: "https://github.com/KRTirtho/flutter_desktop_tools.git" + source: git version: "0.0.1" flutter_distributor: dependency: "direct dev" @@ -1455,9 +1457,11 @@ packages: smtc_windows: dependency: "direct main" description: - path: "../smtc_windows/packages/smtc_windows" - relative: true - source: path + path: "packages/smtc_windows" + ref: "6cc93624b8fab8d7727c8693e91577a7413ccd13" + resolved-ref: "6cc93624b8fab8d7727c8693e91577a7413ccd13" + url: "https://github.com/KRTirtho/smtc_windows.git" + source: git version: "0.0.1" source_gen: dependency: transitive diff --git a/pubspec.yaml b/pubspec.yaml index 97fe1daae..0d195f2dc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -83,9 +83,14 @@ dependencies: path: plugins/window_size youtube_explode_dart: ^1.12.1 flutter_desktop_tools: - path: ../flutter_desktop_tools + git: + url: https://github.com/KRTirtho/flutter_desktop_tools.git + ref: 2fca12d1767dad41421e846383d99ac26e29d202 smtc_windows: - path: ../smtc_windows/packages/smtc_windows + git: + url: https://github.com/KRTirtho/smtc_windows.git + ref: 6cc93624b8fab8d7727c8693e91577a7413ccd13 + path: packages/smtc_windows dev_dependencies: build_runner: ^2.3.2