private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (_waveSource != null)
     {
         Position = _waveSource.GetPosition();
     }
 }
Exemplo n.º 2
0
        //Timer
        private void timer_Tick(object sender, EventArgs e)
        {
            //Start
            progressBar.Maximum = length;
            progressBar.Value   = (int)audio.GetPosition().TotalSeconds;

            //Label
            label_progress.Text = "";

            if (progressBar.Value / 60 < 10)
            {
                label_progress.Text += "0" + progressBar.Value / 60 + ":";
            }
            else
            {
                label_progress.Text += progressBar.Value / 60 + ":";
            }

            if (progressBar.Value % 60 < 10)
            {
                label_progress.Text += "0" + progressBar.Value % 60;
            }
            else
            {
                label_progress.Text += progressBar.Value % 60;
            }

            //End
            if (progressBar.Value == length)
            {
                timer.Stop();
            }
        }
Exemplo n.º 3
0
 private void UpdateMillis()
 {
     lastMillis = CurrentMillis;
     if (currentMusic != null)
     {
         CurrentMillis = (int)currentMusic.GetPosition().TotalMilliseconds;
     }
     // Console.WriteLine(currentMillis);
 }
Exemplo n.º 4
0
        public int TimeLeftms(AudioData audio)
        {
            IWaveSource ws = audio.data as IWaveSource;

            System.Diagnostics.Debug.Assert(ws != null);
            TimeSpan l    = ws.GetLength();
            TimeSpan p    = ws.GetPosition();
            TimeSpan togo = l - p;

            return((int)togo.TotalMilliseconds);
        }
Exemplo n.º 5
0
 public TimeSpan Posicion()
 {
     if (FormatoSonido != FormatoSonido.CDA)
     {
         return(_sound.GetPosition());
     }
     else
     {
         return(SectoresATimeSpan(_sound.Position));
     }
 }
Exemplo n.º 6
0
        private void CountTimerDelegate()
        {
            double totalMS = iws.GetLength().TotalMilliseconds;

            while (iws.GetPosition().TotalMilliseconds <= totalMS)
            {
                if (isPlaying)
                {
                    AudioDelegations.PostionChanged?.Invoke(iws.GetPosition());
                    LyricToken lt;
                    if ((lt = lEnum.Enumerating(iws.GetPosition())) != null)
                    {
                        AudioDelegations.LyricUpdated?.Invoke(lt);
                    }
                }
                Thread.Sleep(1000);
            }
            isPlaying = false;
            AudioDelegations.PlayingFinished?.Invoke();
        }
Exemplo n.º 7
0
        private void timer_setPos_Tick(object sender, EventArgs e)
        {
            if (waveSource == null)
            {
                return;
            }
            if (soundOut == null)
            {
                return;
            }

            if (soundOut.PlaybackState != PlaybackState.Playing)
            {
                return;
            }

            tbar_pos.Value = (int)waveSource.GetPosition().TotalMilliseconds;

            // Lyric Sync
            for (int i = 0; i < lbox_lrc.Items.Count; i++)
            {
                string txt  = (string)lbox_lrc.Items[i];
                var    time = GetLrcTimeCode(txt);
                if (!time.HasValue)
                {
                    continue;
                }

                if (time.Value >= waveSource.GetPosition())
                {
                    lbl_lrc_p.Text = (i > 1 ? GetPureLyric((string)lbox_lrc.Items[i - 2]) : string.Empty);
                    lbl_lrc_c.Text = (i > 0 ? GetPureLyric((string)lbox_lrc.Items[i - 1]) : "Start of File");
                    lbl_lrc_n.Text = GetPureLyric(txt);

                    return;
                }
            }
        }
Exemplo n.º 8
0
 public TimeSpan Posicion()
 {
     return(_sonido.GetPosition());
 }