/// <summary> /// Pauses if <see cref="IsPaused"/> is set to false. /// </summary> public Task PauseAsync() { if (!IsPlaying) { throw new InvalidOperationException(InvalidOp); } Volatile.Write(ref isPaused, true); var payload = new PausePayload(VoiceChannel.GuildId, IsPaused); return(_socketHelper.SendPayloadAsync(payload)); }
/// <summary> /// Pauses if <see cref="IsPaused"/> is set to false. /// </summary> public Task PauseAsync() { if (!this.IsPlaying) { throw new InvalidOperationException(INVALID_OP); } Volatile.Write(ref this._isPaused, true); var payload = new PausePayload(this.VoiceChannel.GuildId, this.IsPaused); return(this._socketHelper.SendPayloadAsync(payload)); }
/// <summary> /// Pauses the current track if any is playing. /// </summary> public async Task PauseAsync() { if (!PlayerState.EnsureState()) { throw new InvalidOperationException( "Player state doesn't match any of the following states: Connected, Playing, Paused."); } var payload = new PausePayload(VoiceChannel.GuildId, true); await _sock.SendAsync(payload) .ConfigureAwait(false); PlayerState = PlayerState.Paused; }
/// <summary> /// Resumes the current track if any is playing. /// </summary> public async Task ResumeAsync() { if (PlayerState == PlayerState.None) { throw new InvalidOperationException( "Player's current state is set to None. Please make sure Player is connected to a voice channel."); } PlayerState = Track is null ? PlayerState.Stopped : PlayerState.Playing; var payload = new PausePayload(VoiceChannel.GuildId, false); await _lavaSocket.SendAsync(payload) .ConfigureAwait(false); }
/// <summary> /// Resumes the current track if any is playing. /// </summary> public async Task ResumeAsync() { if (!PlayerState.EnsureState()) { throw new InvalidOperationException( "Player state doesn't match any of the following states: Connected, Playing, Paused."); } PlayerState = Track is null ? PlayerState.Stopped : PlayerState.Playing; var payload = new PausePayload(VoiceChannel.GuildId, false); await _lavaSocket.SendAsync(payload) .ConfigureAwait(false); }