mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-11-21 20:00:49 +01:00
While the desktop plays in the phone's place: - Reordering or removing queue rows edits the desktop queue through new `move` and `remove` commands, applied on the phone at once. Queue rows are distinct objects so a song queued twice keeps separate rows. - The system media session switches to a RemoteMediaSession through a SwitchAudioHandler: the notification, lock screen and headset show and drive the desktop. Car browsing stays local, and a Library song picked in the car plays on the phone and hands the session back. - Picking a song only the phone has shows "Sending this song to (desktop)..." with its upload progress in Now Playing and the mini player.
61 lines
2.1 KiB
Dart
61 lines
2.1 KiB
Dart
import 'package:audio_service/audio_service.dart';
|
|
import 'package:mornye/services/playable_media.dart';
|
|
|
|
/// Another device playing in this one's place, such as a computer paired
|
|
/// through Mornye Link. While one is active, the player screens show what it
|
|
/// plays and their controls drive it; the local player stays paused.
|
|
///
|
|
/// Each stream starts with the current value, like the local player's
|
|
/// events, and the playback states keep coming while it plays so positions
|
|
/// move.
|
|
abstract interface class RemotePlayback {
|
|
/// The device's name, shown as where the music plays.
|
|
String get name;
|
|
|
|
Stream<MediaItem?> get mediaItems;
|
|
Stream<PlaybackState> get playbackStates;
|
|
Stream<List<MediaItem>> get queues;
|
|
|
|
/// Its volume, 0 to 1, which the player's volume slider sets.
|
|
Stream<double> get volumes;
|
|
Future<void> setVolume(double value);
|
|
|
|
/// Songs on their way there before it can play them, or null while none
|
|
/// travel.
|
|
Stream<RemoteTransfer?> get transfers;
|
|
|
|
Future<void> play();
|
|
Future<void> pause();
|
|
Future<void> seek(Duration position);
|
|
Future<void> next();
|
|
Future<void> previous();
|
|
|
|
/// Plays entry [index] of the queue [queues] reports.
|
|
Future<void> jumpTo(int index);
|
|
|
|
/// Moves entry [from] of that queue to position [to].
|
|
Future<void> moveQueueItem(int from, int to);
|
|
|
|
/// Removes [item], an entry of that queue other than the current one.
|
|
Future<void> removeQueueItem(MediaItem item);
|
|
Future<void> setShuffle(bool enabled);
|
|
Future<void> setRepeatMode(AudioServiceRepeatMode mode);
|
|
|
|
/// Starts [items] there, from [initialIndex], as the local player would.
|
|
Future<void> playAll(List<PlayableMedia> items, {int initialIndex = 0});
|
|
|
|
/// Adds [items] there, after the current song when [playNext].
|
|
Future<void> enqueue(List<PlayableMedia> items, {bool playNext = false});
|
|
}
|
|
|
|
/// A song file being sent to a [RemotePlayback]: [sent] of [total] bytes.
|
|
class RemoteTransfer {
|
|
const RemoteTransfer({required this.sent, required this.total});
|
|
|
|
final int sent;
|
|
final int total;
|
|
|
|
/// The share sent, 0 to 1, or null while the size is unknown.
|
|
double? get fraction => total > 0 ? (sent / total).clamp(0.0, 1.0) : null;
|
|
}
|