/// <summary> /// Seeks the <see cref="CurrentTrack"/> to specified <paramref name="position"/>. /// </summary> /// <param name="position">Position must be less than <see cref="CurrentTrack"/>'s position.</param> public Task SeekAsync(TimeSpan position) { if (!IsPlaying) { throw new InvalidOperationException(InvalidOp); } if (position > CurrentTrack.Length) { throw new ArgumentOutOfRangeException($"{nameof(position)} is greater than current track's length."); } var payload = new SeekPayload(VoiceChannel.GuildId, position); return(_socketHelper.SendPayloadAsync(payload)); }
/// <summary> /// Seeks the <see cref="CurrentTrack"/> to specified <paramref name="position"/>. /// </summary> /// <param name="position">Position must be less than <see cref="CurrentTrack"/>'s position.</param> public Task SeekAsync(TimeSpan position) { if (!this.IsPlaying) { throw new InvalidOperationException(INVALID_OP); } if (position > this.CurrentTrack.Length || position <= TimeSpan.Zero) { throw new ArgumentOutOfRangeException($"{nameof(position)} is out of acceptable range."); } this.CurrentTrack.Position = position; var payload = new SeekPayload(this.VoiceChannel.GuildId, position); return(this._socketHelper.SendPayloadAsync(payload)); }
/// <summary> /// Seeks the current track to specified position. /// </summary> /// <param name="position">Position must be less than <see cref="LavaTrack.Duration" />.</param> /// <returns></returns> public async Task SeekAsync(TimeSpan?position) { if (position == null) { throw new ArgumentNullException(nameof(position)); } 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."); } if (position.Value.TotalMilliseconds > Track.Duration.TotalMilliseconds) { throw new ArgumentOutOfRangeException(nameof(position), $"Value must be no bigger than {Track.Duration.TotalMilliseconds}ms."); } var payload = new SeekPayload(VoiceChannel.GuildId, position.Value); await _lavaSocket.SendAsync(payload) .ConfigureAwait(false); }
/// <summary> /// Seeks the current track to specified position. /// </summary> /// <param name="position">Position must be less than <see cref="LavaTrack.Duration" />.</param> /// <returns></returns> public async Task SeekAsync(TimeSpan?position) { if (position == null) { throw new ArgumentNullException(nameof(position)); } if (!PlayerState.EnsureState()) { throw new InvalidOperationException( "Player state doesn't match any of the following states: Connected, Playing, Paused."); } if (position.Value.TotalMilliseconds > Track.Duration.TotalMilliseconds) { throw new ArgumentOutOfRangeException(nameof(position), $"Value must be no bigger than {Track.Duration.TotalMilliseconds}ms."); } var payload = new SeekPayload(VoiceChannel.GuildId, position.Value); await _lavaSocket.SendAsync(payload) .ConfigureAwait(false); }