Esempio n. 1
0
		/// <summary>
		/// Advances the queue to a specific track, if it can be found.
		/// </summary>
		/// <param name="t">The track to advance to.</param>
		/// <returns>Whether the queue's <seealso cref="Current"/> property is non-null.</returns>
		private bool MoveTo(UniqueTrack t)
		{
			return MutateQueue(() => _queue.MoveTo(t));
		}
Esempio n. 2
0
		/// <summary>
		/// Removes a single track from the queue.
		/// </summary>
		/// <param name="t">The track to remove.</param>
		public void Remove(UniqueTrack t)
		{
			MutateQueue(() => _queue.Remove(t));
		}
Esempio n. 3
0
		/// <summary>
		/// Calls the <seealso cref="CurrentTrackFailed"/> event handler if it is non-null.
		/// </summary>
		/// <param name="t">The <seealso cref="UniqueTrack"/> encapsulating the <seealso cref="Track"/> whose playback has failed.</param>
		protected void OnCurrentTrackFailed(UniqueTrack t)
		{
			EventHandler<TrackEventArgs> h = CurrentTrackFailed;

			if (h != null)
			{
				h(this, new TrackEventArgs(t));
			}
		}
Esempio n. 4
0
		/// <summary>
		/// Attemps to start playback of a particular track.
		/// Its file wille be opened if, and only if, the track can be found.
		/// Otherwise, nothing will happen.
		/// </summary>
		/// <param name="t">The track to play.</param>
		/// <exception cref="InvalidOperationException">if <seealso cref="Status"/> is <seealso cref="AudioControllerStatus.NotReady"/>.</exception>
		public void Play(UniqueTrack t)
		{
			Contract.Requires<InvalidOperationException>(Status != AudioControllerStatus.NotReady);

			if (MoveTo(t))
			{
				Status = AudioControllerStatus.Playing;
				OpenTrackStream(resetPosition: true);
			}
		}
Esempio n. 5
0
		/// <summary>
		/// Creates a new <seealso cref="TrackEventArgs"/>.
		/// </summary>
		/// <param name="t">The <seealso cref="UniqueTrack"/> associated with the previous state.</param>
		/// <param name="time">Optional. The time when the track started playing.</param>
		/// <param name="position">Optional. The position of track playback.</param>
		public TrackEventArgs(UniqueTrack t, DateTime time = new DateTime(), TimeSpan position = new TimeSpan())
		{
			_UniqueTrack = t;
			_StartTimeUtc = time;
			_Position = position;
		}
Esempio n. 6
0
		/// <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;
		}
Esempio n. 7
0
 /// <summary>
 /// Removes an upcoming track in the queue.
 /// Sets UserMutatedQueue to true.
 /// </summary>
 /// <param name="t">The track to remove.</param>
 public bool Remove(UniqueTrack t)
 {
     bool removed = _trackList.Remove(t);
     if (removed)
     {
         UserMutatedQueue = true;
         return true;
     }
     return false;
 }
Esempio n. 8
0
        /// <summary>
        /// Advances the track queue forward to a specified element is possible.
        /// If there were no tracks to begin with, does nothing.
        /// If the last track is hit, clears the queue.
        /// </summary>
        /// <param name="t">The track to advance to.</param>
        /// <returns>If there are no tracks left after advancing, returns false. Otherwise, returns true.</returns>
        public bool MoveTo(UniqueTrack t)
        {
            if (_trackList.Count == 0)
            {
                Clear();
            }
            else
            {
                int index = _trackList.IndexOf(t);
                if (index != -1)
                {
                    _trackList.Dequeue(index);
                }
            }

            return (_trackList.HasCurrent);
        }