コード例 #1
0
ファイル: MediaPlayer.cs プロジェクト: GDxU/GoalRush
        internal static void OnSongFinishedPlaying(object sender, EventArgs args)
        {
            // TODO: Check args to see if song sucessfully played
            _numSongsInQueuePlayed++;

            if (_numSongsInQueuePlayed >= _queue.Count)
            {
                _numSongsInQueuePlayed = 0;
                if (!IsRepeating)
                {
                    Stop();

                    if (ActiveSongChanged != null)
                    {
                        ActiveSongChanged.Invoke(null, null);
                    }

                    return;
                }
            }

#if WINDOWS_PHONE
            if (IsRepeating)
            {
                System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    _mediaElement.Position = TimeSpan.Zero;
                    _mediaElement.Play();
                });
            }
#endif

            MoveNext();
        }
コード例 #2
0
ファイル: MediaPlayer.cs プロジェクト: TheDuderist/MonoGame
        private static void NextSong(int direction)
        {
            Stop();
            if (IsRepeating && Queue.ActiveSongIndex >= Queue.Count - 1)
            {
                Queue.ActiveSongIndex = 0;

                /* Setting direction to 0 will force the first song
                 * in the queue to be played.
                 * if we're on "shuffle", then it'll pick a random one
                 * anyway, regardless of the "direction".
                 */
                direction = 0;
            }

            Song nextSong = Queue.GetNextSong(direction, IsShuffled);

            if (nextSong != null)
            {
                PlaySong(nextSong);
            }

            if (ActiveSongChanged != null)
            {
                ActiveSongChanged.Invoke(null, null);
            }
        }
コード例 #3
0
ファイル: MediaPlayer.cs プロジェクト: TheDuderist/MonoGame
        /// <summary>
        /// The Play method clears the current playback queue and queues the specified song
        /// for playback. Playback starts immediately at the beginning of the song.
        /// </summary>
        public static void Play(Song song)
        {
            Song previousSong = Queue.Count > 0 ? Queue[0] : null;

            Queue.Clear();
            numSongsInQueuePlayed = 0;
            Queue.Add(song);
            Queue.ActiveSongIndex = 0;

            PlaySong(song);

            if (previousSong != song && ActiveSongChanged != null)
            {
                ActiveSongChanged.Invoke(null, EventArgs.Empty);
            }
        }
コード例 #4
0
ファイル: MediaPlayer.cs プロジェクト: GDxU/GoalRush
        /// <summary>
        /// Play clears the current playback queue, and then queues up the specified song for playback.
        /// Playback starts immediately at the given position of the song.
        /// </summary>
        public static void Play(Song song, TimeSpan?startPosition)
        {
            var previousSong = _queue.Count > 0 ? _queue[0] : null;

            _queue.Clear();
            _numSongsInQueuePlayed = 0;
            _queue.Add(song);
            _queue.ActiveSongIndex = 0;

            PlaySong(song, startPosition);

            if (previousSong != song && ActiveSongChanged != null)
            {
                ActiveSongChanged.Invoke(null, EventArgs.Empty);
            }
        }
コード例 #5
0
ファイル: MediaPlayer.cs プロジェクト: DrPandemic/EraParadox
        private static void NextSong(int direction)
        {
            var nextSong = _queue.GetNextSong(direction, IsShuffled);

            if (nextSong == null)
            {
                Stop();
            }
            else
            {
                Play(nextSong);
            }

            if (ActiveSongChanged != null)
            {
                ActiveSongChanged.Invoke(null, null);
            }
        }
コード例 #6
0
ファイル: MediaPlayer.cs プロジェクト: TheDuderist/MonoGame
        internal static void OnSongFinishedPlaying(object sender, EventArgs args)
        {
            // TODO: Check args to see if song sucessfully played.
            numSongsInQueuePlayed += 1;

            if (numSongsInQueuePlayed >= Queue.Count)
            {
                numSongsInQueuePlayed = 0;
                if (!IsRepeating)
                {
                    Stop();

                    if (ActiveSongChanged != null)
                    {
                        ActiveSongChanged.Invoke(null, null);
                    }

                    return;
                }
            }

            MoveNext();
        }
コード例 #7
0
ファイル: SpotifyHook.cs プロジェクト: djgerman10/EZBlocker3
 /// <summary>
 /// OnActiveSongChanged is called whenever the currently active song changes.
 /// </summary>
 /// <param name="eventArgs"></param>
 protected virtual void OnActiveSongChanged(ActiveSongChangedEventArgs eventArgs) {
     Logger.LogInfo($"SpotifyHook: Active song: \"{eventArgs.NewActiveSong}\"");
     ActiveSongChanged?.Invoke(this, eventArgs);
 }