예제 #1
0
        private void BassPlayerLoad(string url)
        {
            Un4seen.Bass.BASSActive isActive = default(Un4seen.Bass.BASSActive);

            isActive = Bass.BASS_ChannelIsActive(stream);
            if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING)
            {
                Bass.BASS_ChannelStop(stream);
            }

            // If ofd.FileName = "" Then Exit Sub
            stream = Bass.BASS_StreamCreateFile(url, 0, 0, BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_STREAM_PRESCAN);
            //stream = Bass.BASS_StreamCreateURL(url, 0, BASSFlag.BASS_DEFAULT, null, IntPtr.Zero);

            //  stream = Bass.BASS_Stream
            Bass.BASS_ChannelPlay(stream, false);
            Un4seen.Bass.BASS_CHANNELINFO    CI = new Un4seen.Bass.BASS_CHANNELINFO();
            Un4seen.Bass.AddOn.Tags.TAG_INFO TI = new Un4seen.Bass.AddOn.Tags.TAG_INFO();

            // WF = New Un4seen.Bass.Misc.WaveForm(ofd.FileName, New Un4seen.Bass.Misc.WAVEFORMPROC(AddressOf MyWaveFormCallback), Me)
            // WF.RenderStart(True, BASSFlag.BASS_DEFAULT)

            tmrUpdateControls.Start();
            tmrVisuals.Start();

            TagLib.File f = TagLib.File.Create(url);
            lblTrackInfo.Text       = f.Tag.Artists[0] + " - " + f.Tag.Title;
            cmdPlay.BackgroundImage = pbPausePick.BackgroundImage;

            currentPlayingTrackFile = url;
            tmrUpdateControls_Tick(null, null);
        }
예제 #2
0
        private void tmrVisuals_Tick(object sender, EventArgs e)
        {
            Graphics g = Graphics.FromImage(bmp);

            float[] d = new float[1024];

            g.Clear(Color.White);
            Un4seen.Bass.BASSActive isActive = default(Un4seen.Bass.BASSActive);
            isActive = Bass.BASS_ChannelIsActive(stream);

            if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING)
            {
                Bass.BASS_ChannelGetData(stream, d, (int)Un4seen.Bass.BASSData.BASS_DATA_FFT1024);
            }
            else if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PAUSED)
            {
                for (int i = 0; i <= 1023; i++)
                {
                    d[i] = d[i] - 0.002F;
                    d[i] = Math.Max(d[i], 0);
                }
            }

            int   amount = 512;
            int   step = (int)(1024 / amount);
            float x, y, w, h;

            int j = -1;

            for (int i = 0; i < 1024; i += step)
            {
                j++;
                x = ((float)i / (float)amount * bmp.Width);
                w = Math.Max(((float)bmp.Width / (float)amount), 3);

                y = bmp.Height * (1 - d[i] * dIncreaser(i, 1024)) - 2;
                h = bmp.Height + 2;// -y - 3;

                g.FillRectangle(b, x, y, w, h - y);

                dd[i] = dd[i] - 0.002F;
                if (dd[i] < d[i])
                {
                    dd[i] = d[i];
                }

                y = bmp.Height * (1 - dd[i] * dIncreaser(i, 1024)) - 2;
                g.FillRectangle(b2, x, y, w, 2);
            }
            pbVisuals.Image = bmp;
        }
예제 #3
0
        private void tmrUpdateControls_Tick(object sender, EventArgs e)
        {
            if (stream == -1)
            {
                return;
            }
            try
            {
                long pos = 0;
                long len = 0;
                len = Bass.BASS_ChannelGetLength(stream);
                pos = Bass.BASS_ChannelGetPosition(stream);

                double tElapsed = 0;
                double tRemain  = 0;
                double tLength  = 0;
                tLength       = Bass.BASS_ChannelBytes2Seconds(stream, len);
                tElapsed      = Bass.BASS_ChannelBytes2Seconds(stream, pos);
                tRemain       = tLength - tElapsed;
                lblTime2.Text = Un4seen.Bass.Utils.FixTimespan(tLength, "MMSS");
                lblTime1.Text = Un4seen.Bass.Utils.FixTimespan(tElapsed, "MMSS");

                trbPosition.MaxValue = (int)(Bass.BASS_ChannelGetLength(stream) / 1000);

                TaskbarManager.Instance.SetProgressValue((int)(Bass.BASS_ChannelGetPosition(stream) / 1000), (int)(Bass.BASS_ChannelGetLength(stream) / 1000), this.Handle);

                if (!shouldChangePosition)
                {
                    trbPosition.Value = (int)(Bass.BASS_ChannelGetPosition(stream) / 1000);
                    if (tRemain == 0)
                    {
                        if (lbFiles.Items.Count > 1)
                        {
                            cmdNext.PerformClick();
                        }
                    }
                }

                Un4seen.Bass.BASSActive isActive = default(Un4seen.Bass.BASSActive);
                isActive = Bass.BASS_ChannelIsActive(stream);
                if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING)
                {
                    TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal);
                }
                else if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PAUSED)
                {
                    TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Paused);
                }
            }
            catch (Exception ex) { }
        }
예제 #4
0
 private void cmdPlay_Click(object sender, EventArgs e)
 {
     Un4seen.Bass.BASSActive isActive = default(Un4seen.Bass.BASSActive);
     isActive = Bass.BASS_ChannelIsActive(stream);
     if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING)
     {
         Bass.BASS_ChannelPause(stream);
         cmdPlay.BackgroundImage = pbPlayPic.BackgroundImage;
         TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Paused);
     }
     else if (isActive == Un4seen.Bass.BASSActive.BASS_ACTIVE_PAUSED)
     {
         Bass.BASS_ChannelPlay(stream, false);
         cmdPlay.BackgroundImage = pbPausePick.BackgroundImage;
         TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal);
     }
 }
예제 #5
0
        /// <summary>
        /// Pause or unpause the sound
        /// </summary>
        public void pauseUnpause()
        {
            switch (engine)
            {
            case Engines.Bass:
                Un4seen.Bass.BASSActive isPlaying = Bass.BASS_ChannelIsActive(stream);
                if (isPlaying == Un4seen.Bass.BASSActive.BASS_ACTIVE_PLAYING)
                {
                    Bass.BASS_ChannelPause(stream);
                }
                else
                {
                    Bass.BASS_ChannelPlay(stream, false);
                }
                break;

            case Engines.IrrKlang:
                sound.Paused = !sound.Paused;
                break;
            }
        }