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(); }
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); } }
/// <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); } }
/// <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); } }
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); } }
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(); }
/// <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); }