예제 #1
0
        private void CopyEventsSubscriptionsHandler(out List <TimeChangedDelegate> durationChangedSubscriptions,
                                                    out List <TimeChangedDelegate> currentTimeChangedSubscriptions,
                                                    out List <TimeDelegate> timeFlowStartedSubscriptions,
                                                    out List <TimeDelegate> timeFlowStoppedSubscriptions,
                                                    out List <TimeDelegate> timeFlowPausedSubscriptions)
        {
            durationChangedSubscriptions    = new List <TimeChangedDelegate>();
            currentTimeChangedSubscriptions = new List <TimeChangedDelegate>();
            timeFlowStartedSubscriptions    = new List <TimeDelegate>();
            timeFlowStoppedSubscriptions    = new List <TimeDelegate>();
            timeFlowPausedSubscriptions     = new List <TimeDelegate>();

            if (DurationChanged != null)
            {
                durationChangedSubscriptions = Array.ConvertAll(DurationChanged.GetInvocationList(), item => (TimeChangedDelegate)item).ToList();
            }
            if (CurrentTimeChanged != null)
            {
                currentTimeChangedSubscriptions = Array.ConvertAll(CurrentTimeChanged.GetInvocationList(), item => (TimeChangedDelegate)item).ToList();
            }
            if (TimeFlowStarted != null)
            {
                timeFlowStartedSubscriptions = Array.ConvertAll(TimeFlowStarted.GetInvocationList(), item => (TimeDelegate)item).ToList();
            }
            if (TimeFlowStopped != null)
            {
                timeFlowStoppedSubscriptions = Array.ConvertAll(TimeFlowStopped.GetInvocationList(), item => (TimeDelegate)item).ToList();
            }
            if (TimeFlowPaused != null)
            {
                timeFlowPausedSubscriptions = Array.ConvertAll(TimeFlowPaused.GetInvocationList(), item => (TimeDelegate)item).ToList();
            }
        }
예제 #2
0
 public void ChangeCurrentTime(long timestamp)
 {
     player.SourceProvider.MediaPlayer.Time = timestamp;
     CurrentTimeChanged?.Invoke(this, new CurrentTimeChangedEventArgs {
         CurrentTime = timestamp
     });
 }
예제 #3
0
        /// <summary> Set timeflow current time.</summary>
        /// <param name="seconds">Current time in seconds to be set.</param>
        /// <param name="invokeEvents"> True, if method should invoke TimeChange event</param>
        public void SetTime(double seconds, bool invokeEvents = true)
        {
            TimeSpan oldTime = _time;

            _time = MakeTimeSpan(seconds);
            if (_time >= Duration)
            {
                StopTimeFlowEngine();
                _time = Duration;
            }
            if (invokeEvents && oldTime != _time && CurrentTimeChanged != null)
            {
                CurrentTimeChanged.Invoke(oldTime, _time);
            }
        }
 private void OnCurrentTimeChanged(IEnumerable <PlaybackCurrentTime> times)
 {
     CurrentTimeChanged?.Invoke(this, new PlaybackCurrentTimeChangedEventArgs(times));
 }
예제 #5
0
        public void SelectFile(string fileName)
        {
            InvalidFile = false;
            InvalidFileChanged?.Invoke(this, EventArgs.Empty);

            if (Playing)
            {
                Stop();
            }

            _source = null;

            string extension = Path.GetExtension(fileName).ToLower();

            try
            {
                if (extension == ".mp3")
                {
                    _source = new Mp3FileReader(fileName);
                }
                else if (extension == ".wav")
                {
                    _source = new WaveFileReader(fileName);
                }
                else if ((extension == ".fla") || (extension == ".flac"))
                {
                    _source = new FlacReader(fileName);
                }
            }
            catch
            {
                InvalidFile = true;
                InvalidFileChanged?.Invoke(this, EventArgs.Empty);

                _source = null;
            }

            TotalTimeChanged?.Invoke(this, EventArgs.Empty);

            if (_source == null)
            {
                return;
            }

            _stretcher = new RubberBandWaveStream(_source);

            _stretcher.SourceRead +=
                (sender, e) =>
            {
                CurrentTimeChanged?.Invoke(this, e);
            };

            _stretcher.EndOfStream +=
                (sender, e) =>
            {
                ReachedEnd?.Invoke(this, e);
                Stop();
            };

            TempoChanged?.Invoke(this, EventArgs.Empty);
            CurrentTimeChanged?.Invoke(this, EventArgs.Empty);

            _waveOut.Init(_stretcher);
        }
예제 #6
0
 public void RefreshTime()
 {
     CurrentTimeChanged?.Invoke(this, EventArgs.Empty);
 }