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 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(); } }