Exemplo n.º 1
0
        private void timerUpdate_Tick(object sender, EventArgs e)
        {
            // here we gather info about the stream, when it is playing...
            if (_handle == 0 || Bass.ChannelIsActive(_handle) != PlaybackState.Playing && Bass.ChannelIsActive(_handle) != PlaybackState.Paused)
            {
                // the stream is NOT playing anymore...
                _UpdateTimer.Stop();
                _PositionTrack.Value = 0;
                picSpectrum.Image    = null;
                _vis.ClearPeaks();
                return;
            }

            // from here on, the stream is for sure playing...
            _TickCounter++;

            if (_TickCounter == 2)
            {
                _TickCounter = 0;

                this.labelInfo.Text = string.Format("{0:#0.00} / {1:#0.00}", Utils.TSHMSF(Position), Utils.TSHMSF(_Length));
            }

            _PositionTrack.Value = (int)(Math.Round((Position / _Length), 2) * _PositionTrack.Maximum);

            // update spectrum
            DrawSpectrum();
        }
Exemplo n.º 2
0
        public void Play(bool Restart = false)
        {
            if (_handle != 0)
            {
                if (Bass.ChannelIsActive(_handle) == PlaybackState.Stopped || Bass.ChannelIsActive(_handle) == PlaybackState.Paused)
                {
                    if (Loop)
                    {
                        Bass.ChannelAddFlag(_handle, BassFlags.Loop);
                    }
                    else
                    {
                        Bass.ChannelRemoveFlag(_handle, BassFlags.Loop);
                    }

                    if (!Bass.ChannelPlay(_handle, Restart))
                    {
                        Console.WriteLine("Player: Error Playing {0:G}", Bass.LastError);
                        _handle = 0;
                        return;
                    }
                }

                _UpdateTimer.Start();
            }
        }
Exemplo n.º 3
0
 public void Stop()
 {
     if (_handle != 0)
     {
         if (Bass.ChannelIsActive(_handle) == PlaybackState.Playing || Bass.ChannelIsActive(_handle) == PlaybackState.Paused)
         {
             Bass.ChannelStop(_handle);
         }
     }
 }
Exemplo n.º 4
0
 public void Pause()
 {
     if (_handle != 0)
     {
         if (Bass.ChannelIsActive(_handle) == PlaybackState.Playing)
         {
             Bass.ChannelPause(_handle);
         }
     }
 }