mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-09-29 21:02:09 +02:00
Sync notification favorites with Library, add Mornye transport icons and an output action on legacy Android, and expose the iOS favorite command. Preserve playback position when controls refresh. Vendor audio_service 0.18.19 with a small Android patch for custom notification actions. Modern Android keeps its system output switcher and transport layout.
64 lines
1.8 KiB
Dart
64 lines
1.8 KiB
Dart
import 'package:audio_service/audio_service.dart';
|
|
|
|
/// Presentation only; every transport action still uses the audio handler.
|
|
class PlaybackNotification {
|
|
static const favoriteAction = 'spotiflac.favorite';
|
|
static const outputAction = 'spotiflac.audioOutput';
|
|
|
|
final bool mornye;
|
|
final String? mediaId;
|
|
final String? source;
|
|
final bool loved;
|
|
final String favoriteLabel;
|
|
final String outputLabel;
|
|
|
|
const PlaybackNotification({
|
|
this.mornye = false,
|
|
this.mediaId,
|
|
this.source,
|
|
this.loved = false,
|
|
this.favoriteLabel = 'Favorite',
|
|
this.outputLabel = 'Audio Output',
|
|
});
|
|
|
|
List<MediaControl> controls({
|
|
required bool playing,
|
|
required MediaItem? item,
|
|
}) {
|
|
if (!mornye) {
|
|
return [
|
|
MediaControl.skipToPrevious,
|
|
playing ? MediaControl.pause : MediaControl.play,
|
|
MediaControl.skipToNext,
|
|
];
|
|
}
|
|
final current = item?.id == mediaId && item?.extras?['source'] == source;
|
|
return [
|
|
MediaControl.custom(
|
|
name: favoriteAction,
|
|
androidIcon: current && loved
|
|
? 'drawable/ic_notification_star_filled'
|
|
: 'drawable/ic_notification_star',
|
|
label: favoriteLabel,
|
|
),
|
|
MediaControl.skipToPrevious.copyWith(
|
|
androidIcon: 'drawable/ic_widget_previous',
|
|
),
|
|
(playing ? MediaControl.pause : MediaControl.play).copyWith(
|
|
androidIcon: playing
|
|
? 'drawable/ic_widget_pause'
|
|
: 'drawable/ic_widget_play',
|
|
),
|
|
MediaControl.skipToNext.copyWith(androidIcon: 'drawable/ic_widget_next'),
|
|
MediaControl.custom(
|
|
name: outputAction,
|
|
androidIcon: 'drawable/ic_notification_airplay',
|
|
label: outputLabel,
|
|
extras: const {
|
|
'spotiflac.activity': 'com.zarz.spotiflac.AudioOutputActivity',
|
|
},
|
|
),
|
|
];
|
|
}
|
|
}
|