mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55:18 +00:00
feat: disable/enable smtc on demand
This commit is contained in:
parent
f0b426ae89
commit
7fa50e5c5e
@ -15,7 +15,8 @@ class WindowsAudioService {
|
||||
|
||||
final subscriptions = <StreamSubscription>[];
|
||||
|
||||
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<void> 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<Artist>(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();
|
||||
|
16
pubspec.lock
16
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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user