Exemple #1
0
        public void SongStoppedHook(object sender, SongEndEventArgs e)
        {
            BeforeResourceStopped?.Invoke(this, e);

            if (e.SongEndedByCallback && CurrentPlayData != null)
            {
                R result = Next(CurrentPlayData.Invoker);
                if (result)
                {
                    return;
                }
                Log.Write(Log.Level.Warning, nameof(SongStoppedHook) + " could not play Next: " + result.Message);
            }

            CurrentPlayData = null;
            AfterResourceStopped?.Invoke(this, new EventArgs());
        }
        private void StopInternal(bool songEndedByCallback)
        {
            BeforeResourceStopped?.Invoke(this, new SongEndEventArgs(songEndedByCallback));

            if (songEndedByCallback)
            {
                var result = Next(CurrentPlayData?.Invoker ?? InvokerData.Anonymous, false);
                if (result.Ok)
                {
                    return;
                }
                Log.Info("Song queue ended: {0}", result.Error);
            }
            else
            {
                PlayerConnection.AudioStop();
            }

            CurrentPlayData = null;
            AfterResourceStopped?.Invoke(this, EventArgs.Empty);
        }
        private void Stop(bool songEndedByCallback = false)
        {
            BeforeResourceStopped?.Invoke(this, new SongEndEventArgs(songEndedByCallback));

            if (songEndedByCallback && CurrentPlayData != null)
            {
                R result = Next(CurrentPlayData.Invoker);
                if (result)
                {
                    return;
                }
                Log.Write(Log.Level.Warning, nameof(SongStoppedHook) + " could not play Next: " + result.Message);
            }
            else
            {
                PlayerConnection.AudioStop();
            }

            CurrentPlayData = null;
            AfterResourceStopped?.Invoke(this, new EventArgs());
        }