/// <summary> /// All queue mutation within the AudioController must go through this routing method. /// This method send the appropriate track-change messages if necessary. /// </summary> /// <param name="queueMutationFunction">An anonymous function that returns void.</param> /// <exception cref="ArgumentNullException">if <paramref name="queueMutationFunction"/> is null.</exception> private void MutateQueue(Action queueMutationFunction) { Contract.Requires <ArgumentNullException>(queueMutationFunction != null); var storedTrack = new TrackEventArgs(CurrentUnique, TrackStreamOpenTimeUtc, Position); queueMutationFunction(); OnCurrentTrackChanged(storedTrack); }
/// <summary> /// All queue mutation within the AudioController must go through this routing method. /// This method send the appropriate track-change messages if necessary. /// </summary> /// <param name="queueMutationFunction">An anonymous function that returns a bool.</param> /// <returns>The result of the anonymous function.</returns> /// <exception cref="ArgumentNullException">if <paramref name="queueMutationFunction"/> is null.</exception> private bool MutateQueue(Func <bool> queueMutationFunction) { Contract.Requires <ArgumentNullException>(queueMutationFunction != null); var storedTrack = new TrackEventArgs(CurrentUnique, TrackStreamOpenTimeUtc, Position); var result = queueMutationFunction(); OnCurrentTrackChanged(storedTrack); return(result); }
/// <summary> /// Calls the <seealso cref="CurrentTrackChanged"/> event handler if it is non-null. /// </summary> /// <param name="oldTrackInfo">Information encapsulating the state of the previous track before the track changed.</param> protected void OnCurrentTrackChanged(TrackEventArgs oldTrackInfo) { Contract.Requires(oldTrackInfo != null); if (!oldTrackInfo.UniqueTrack.Equals(CurrentUnique)) { if (oldTrackInfo.UniqueTrack.Track != null) { oldTrackInfo.UniqueTrack.Track.NotifyNowPlaying(); } if (Current != null) { Current.NotifyNowPlaying(); Windows.Media.MediaControl.AlbumArt = Current.Artwork.Image; Windows.Media.MediaControl.ArtistName = Current.Artist; Windows.Media.MediaControl.TrackName = Current.Title; } else { Windows.Media.MediaControl.AlbumArt = null; Windows.Media.MediaControl.ArtistName = string.Empty; Windows.Media.MediaControl.TrackName = string.Empty; } EventHandler <TrackChangedEventArgs> h = CurrentTrackChanged; if (h != null) { h(this, new TrackChangedEventArgs(oldTrackInfo, CurrentUnique)); } UserMutationCount++; OnPropertyChanged("Current"); } }
/// <summary> /// All queue mutation within the AudioController must go through this routing method. /// This method send the appropriate track-change messages if necessary. /// </summary> /// <param name="queueMutationFunction">An anonymous function that returns void.</param> /// <exception cref="ArgumentNullException">if <paramref name="queueMutationFunction"/> is null.</exception> private void MutateQueue(Action queueMutationFunction) { Contract.Requires<ArgumentNullException>(queueMutationFunction != null); var storedTrack = new TrackEventArgs(CurrentUnique, TrackStreamOpenTimeUtc, Position); queueMutationFunction(); OnCurrentTrackChanged(storedTrack); }
/// <summary> /// All queue mutation within the AudioController must go through this routing method. /// This method send the appropriate track-change messages if necessary. /// </summary> /// <param name="queueMutationFunction">An anonymous function that returns a bool.</param> /// <returns>The result of the anonymous function.</returns> /// <exception cref="ArgumentNullException">if <paramref name="queueMutationFunction"/> is null.</exception> private bool MutateQueue(Func<bool> queueMutationFunction) { Contract.Requires<ArgumentNullException>(queueMutationFunction != null); var storedTrack = new TrackEventArgs(CurrentUnique, TrackStreamOpenTimeUtc, Position); var result = queueMutationFunction(); OnCurrentTrackChanged(storedTrack); return result; }
/// <summary> /// Calls the <seealso cref="CurrentTrackChanged"/> event handler if it is non-null. /// </summary> /// <param name="oldTrackInfo">Information encapsulating the state of the previous track before the track changed.</param> protected void OnCurrentTrackChanged(TrackEventArgs oldTrackInfo) { Contract.Requires(oldTrackInfo != null); if (!oldTrackInfo.UniqueTrack.Equals(CurrentUnique)) { if (oldTrackInfo.UniqueTrack.Track != null) { oldTrackInfo.UniqueTrack.Track.NotifyNowPlaying(); } if (Current != null) { Current.NotifyNowPlaying(); Windows.Media.MediaControl.AlbumArt = Current.Artwork.Image; Windows.Media.MediaControl.ArtistName = Current.Artist; Windows.Media.MediaControl.TrackName = Current.Title; } else { Windows.Media.MediaControl.AlbumArt = null; Windows.Media.MediaControl.ArtistName = string.Empty; Windows.Media.MediaControl.TrackName = string.Empty; } EventHandler<TrackChangedEventArgs> h = CurrentTrackChanged; if (h != null) { h(this, new TrackChangedEventArgs(oldTrackInfo, CurrentUnique)); } UserMutationCount++; OnPropertyChanged("Current"); } }
/// <summary> /// Creates a new <seealso cref="TrackChangedEventArgs"/>. /// </summary> /// <param name="oldTrack">The track that was playing before the track change.</param> /// <param name="newTrack">The track that started playing after the track change.</param> public TrackChangedEventArgs(TrackEventArgs oldTrack, UniqueTrack newTrack) : base(oldTrack.UniqueTrack, oldTrack.StartTimeUtc, oldTrack.Position) { Contract.Requires(oldTrack != null); _NewUniqueTrack = newTrack; }
/// <summary> /// Creates a new <seealso cref="TrackChangedEventArgs"/>. /// </summary> /// <param name="oldTrack">The track that was playing before the track change.</param> /// <param name="newTrack">The track that started playing after the track change.</param> public TrackChangedEventArgs(TrackEventArgs oldTrack, UniqueTrack newTrack) : base(oldTrack.UniqueTrack, oldTrack.StartTimeUtc, oldTrack.Position) { Contract.Requires(oldTrack != null); _NewUniqueTrack = newTrack; }
private void AudioController_CurrentTrackFailed(object sender, TrackEventArgs e) { ShowMessageBar(e.Track != null ? string.Format(LocalizationManager.GetString("MainPage/AudioError/Text_F"), e.Track.Title) : LocalizationManager.GetString("MainPage/AudioError/Text")); }