private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (_waveSource != null)
     {
         Position = _waveSource.GetPosition();
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: orogab25/musicPlayer
        //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();
            }
        }
コード例 #3
0
ファイル: SyncrPlayer.cs プロジェクト: msf567/Syncr
 private void UpdateMillis()
 {
     lastMillis = CurrentMillis;
     if (currentMusic != null)
     {
         CurrentMillis = (int)currentMusic.GetPosition().TotalMilliseconds;
     }
     // Console.WriteLine(currentMillis);
 }
コード例 #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);
        }
コード例 #5
0
 public TimeSpan Posicion()
 {
     if (FormatoSonido != FormatoSonido.CDA)
     {
         return(_sound.GetPosition());
     }
     else
     {
         return(SectoresATimeSpan(_sound.Position));
     }
 }
コード例 #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();
        }
コード例 #7
0
ファイル: MainForm.cs プロジェクト: mkaraki/LrcMaker
        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;
                }
            }
        }
コード例 #8
0
 public TimeSpan Posicion()
 {
     return(_sonido.GetPosition());
 }