togglePlayPause method

void togglePlayPause(
  1. String id
)

Implementation

void togglePlayPause(String id) {
  if (isClosed) return;
  final p = state.players[id];
  if (p == null) return;
  if (p.state.playing) {
    p.pause();
    emit(state.copyWith(playingVideos: Set.from(state.playingVideos)..remove(id)));
  } else {
    for (final entry in state.players.entries) { if (entry.key != id && entry.value.state.playing) entry.value.pause(); }
    p.play();
    emit(state.copyWith(playingVideos: {id}));
  }
}