network addition
This commit is contained in:
parent
3bd713d667
commit
2099d3d64d
27 changed files with 2237 additions and 40 deletions
41
lib/remote/command_dispatch.dart
Normal file
41
lib/remote/command_dispatch.dart
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import '../playback/playback_engine.dart';
|
||||
import 'messages.dart';
|
||||
|
||||
/// Apply a wire [RemoteCommand] to a [PlaybackCommands] target — the single
|
||||
/// place the protocol's verbs map onto the playback surface. The host uses it
|
||||
/// to drive its local engine from a remote's commands; keeping it transport-
|
||||
/// free (no sockets) lets the loopback test exercise the mapping directly.
|
||||
Future<void> applyRemoteCommand(
|
||||
PlaybackCommands target,
|
||||
RemoteCommand cmd,
|
||||
) async {
|
||||
switch (cmd.op) {
|
||||
case RemoteOp.playPause:
|
||||
await target.togglePlayPause();
|
||||
case RemoteOp.next:
|
||||
await target.next();
|
||||
case RemoteOp.previous:
|
||||
await target.previous();
|
||||
case RemoteOp.seek:
|
||||
await target.seek(Duration(milliseconds: cmd.positionMs ?? 0));
|
||||
case RemoteOp.jumpTo:
|
||||
await target.jumpTo(cmd.index ?? 0);
|
||||
case RemoteOp.playSongs:
|
||||
await target.playSongs(cmd.songs ?? const [],
|
||||
startIndex: cmd.startIndex ?? 0);
|
||||
case RemoteOp.playNext:
|
||||
if (cmd.song != null) await target.playNext(cmd.song!);
|
||||
case RemoteOp.addToQueue:
|
||||
if (cmd.song != null) await target.addToQueue(cmd.song!);
|
||||
case RemoteOp.removeAt:
|
||||
await target.removeAt(cmd.index ?? 0);
|
||||
case RemoteOp.reorder:
|
||||
await target.reorderQueue(cmd.oldIndex ?? 0, cmd.newIndex ?? 0);
|
||||
case RemoteOp.toggleShuffle:
|
||||
await target.toggleShuffle();
|
||||
case RemoteOp.cycleLoop:
|
||||
await target.cycleLoop();
|
||||
case RemoteOp.retry:
|
||||
await target.retry();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue