Esempio n. 1
0
 /// <summary>
 ///     Stops the current track if any is playing.
 /// </summary>
 public async Task StopAsync()
 {
     PlayerState = PlayerState.Stopped;
     var payload = new StopPayload(VoiceChannel.GuildId);
     await _lavaSocket.SendAsync(payload)
     .ConfigureAwait(false);
 }
Esempio n. 2
0
        /// <summary>
        /// Stops playing the current track and sets <see cref="IsPlaying"/> to false.
        /// </summary>
        public Task StopAsync()
        {
            if (!IsPlaying)
            {
                throw new InvalidOperationException(InvalidOp);
            }

            IsPlaying    = false;
            CurrentTrack = null;
            var payload = new StopPayload(VoiceChannel.GuildId);

            return(_socketHelper.SendPayloadAsync(payload));
        }
Esempio n. 3
0
        /// <summary>
        /// Stops playing the current track and sets <see cref="IsPlaying"/> to false.
        /// </summary>
        public Task StopAsync()
        {
            if (!this.IsPlaying)
            {
                throw new InvalidOperationException(INVALID_OP);
            }

            this.IsPlaying    = false;
            this.CurrentTrack = null;
            Volatile.Write(ref this._isPaused, false);
            var payload = new StopPayload(this.VoiceChannel.GuildId);

            return(this._socketHelper.SendPayloadAsync(payload));
        }
Esempio n. 4
0
        /// <summary>
        /// Disposes <see cref="LavaPlayer"/>, sends a stop and destroy request to Lavalink server and disconnects from <see cref="VoiceChannel"/>.
        /// </summary>
        public async ValueTask DisposeAsync()
        {
            IsPlaying = false;
            Queue.Clear();
            Queue        = null;
            CurrentTrack = null;
            var stopPayload    = new StopPayload(VoiceChannel.GuildId);
            var destroyPayload = new DestroyPayload(VoiceChannel.GuildId);
            await _socketHelper.SendPayloadAsync(stopPayload);

            await _socketHelper.SendPayloadAsync(destroyPayload);

            await VoiceChannel.DisconnectAsync().ConfigureAwait(false);

            GC.SuppressFinalize(this);
        }