playPause method

Future<bool> playPause()

Play/Pause toggle - pauses other players when starting playback

Implementation

Future<bool> playPause() async {
  final currentPlayer = _state.selectedPlayer.isNotEmpty
      ? _state.selectedPlayer
      : null;

  // Check current status to determine if we're about to play
  final currentStatus = _state.currentMedia.status;
  final willPlay = currentStatus != 'Playing';

  // If we're about to play, pause other players first
  if (willPlay) {
    await _pauseOtherPlayers(currentPlayer);
  }

  final success = await _service.playPause(currentPlayer);
  if (!success) {
    _updateState(
      _state.copyWith(errorMessage: 'Failed to toggle play/pause'),
    );
  }
  return success;
}