Exemplo n.º 1
0
 public void OnStatusChanged(BASSActive status)
 {
     if (StatusChanged != null)
     {
         StatusChanged(status);
     }
 }
Exemplo n.º 2
0
        private void M_OnMusicChanged(object sender, EventArgs e)
        {
            pic.BackgroundImage = m.Alboum;
            l1.Text             = m.Itext1; l2.Text = m.Itext2;
            BASSActive b = Bass.BASS_ChannelIsActive(m.stream);

            if (b == BASSActive.BASS_ACTIVE_PAUSED || b == BASSActive.BASS_ACTIVE_STOPPED)
            {
                playpause.Checked = false;

                timer1.Stop();
            }
            else if (b == BASSActive.BASS_ACTIVE_PLAYING)
            {
                playpause.Checked = true;
                timer1.Start();
            }

            if (l1.Width > 150)
            {
                l1.Left = 0;
                timer2.Start();
            }
            else
            {
                l1.Left = 150 / 2 - l1.Width / 2;
                timer2.Stop();
            }
        }
Exemplo n.º 3
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            BASSActive status = GetStreamStatus();

            if (status != CurrentStatus)
            {
                CurrentStatus = status;
                OnStatusChanged(status);
            }
        }
Exemplo n.º 4
0
        void _timer_Tick(object sender, EventArgs e)
        {
            BASSActive status = AudioControllerService.Current.GetStreamStatus();

            //if (status != _lastStatus)
            //{
            //    _lastStatus = status;
            //    _audioPlayer_StatusChanged();
            //}

            switch (status)
            {
            case BASSActive.BASS_ACTIVE_PLAYING:

                //PlayerStatus = PLAYER_STATUS.PLAYING;

                RaisePropertyChanged(() => Position);

                string time;

                if (DisplayMode == DISPLAY_MODE.CURRENT_TIME)
                {
                    time = AudioControllerService.Current.GetElapsedTimeString();
                }
                else
                {
                    time = AudioControllerService.Current.GetRemainingTimeString();
                }

                //BPM = _audioPlayer.BPM.ToString("#0");

                DisplayedTime = time;

                break;

            case BASSActive.BASS_ACTIVE_PAUSED:

                //PlayerStatus = PLAYER_STATUS.PAUSED;

                break;

            case BASSActive.BASS_ACTIVE_STALLED:
                //StreamPercent = _audioPlayer.GetStreamProgress();

                //PlayerStatus = PLAYER_STATUS.STALLED;

                break;

            case BASSActive.BASS_ACTIVE_STOPPED:

                //PlayerStatus = PLAYER_STATUS.STOPPED;

                break;
            }
        }
Exemplo n.º 5
0
        void BassTimer_Tick(object sender, EventArgs e)
        {
            PlayerProgressInformation progress = new PlayerProgressInformation();
            BASSActive state = Bass.BASS_ChannelIsActive(BassStream);

            if (state == BASSActive.BASS_ACTIVE_PLAYING)
            {
                progress.state = PlayState.PLAYING;
            }
            else if (state == BASSActive.BASS_ACTIVE_PAUSED)
            {
                progress.state = PlayState.PAUSED;
            }
            else if (state == BASSActive.BASS_ACTIVE_STOPPED)
            {
                progress.state = PlayState.STOPPED;
            }
            else if (state == BASSActive.BASS_ACTIVE_STALLED)
            {
                progress.state = PlayState.STALLED;
            }

            if (TagInfo != null)
            {
                progress.artist = TagInfo.artist;
                progress.track  = TagInfo.title;
            }
            double totaltime, elapsedtime;

            if (state != BASSActive.BASS_ACTIVE_STOPPED)
            {
                long pos = Bass.BASS_ChannelGetPosition(BassStream);           // position in bytes
                long len = Bass.BASS_ChannelGetLength(BassStream);             // length in bytes
                totaltime   = Bass.BASS_ChannelBytes2Seconds(BassStream, len); // the total time length
                elapsedtime = Bass.BASS_ChannelBytes2Seconds(BassStream, pos); // the elapsed time length
            }
            else
            {
                totaltime = elapsedtime = 0;
            }



            progress.totalLength     = (int)totaltime;
            progress.currentPosition = (int)elapsedtime;


            Program.playerWindow.Invoke(new neprostopleer.PlayerWindow.UpdateGUIStatusDelegate(Program.playerWindow.UpdateGUIStatus), new object[] { progress });

            if (Bass.BASS_ChannelIsActive(BassStream) != BASSActive.BASS_ACTIVE_PLAYING)
            {
                BassTimer.Stop();
            }
        }
Exemplo n.º 6
0
 private void Instance_StatusChanged(BASSActive status)
 {
     switch (status)
     {
     case BASSActive.BASS_ACTIVE_STOPPED:
         foreach (PluginVM plugin in Plugins)
         {
             plugin.Plugin.ChannelDispose();
         }
         break;
     }
 }
Exemplo n.º 7
0
 void dpt_Tick(object sender, EventArgs e)
 {
     if (prevStatus != Bass.BASS_ChannelIsActive(Handle))
     {
         prevStatus = Bass.BASS_ChannelIsActive(Handle);
         if (prevStatus == BASSActive.BASS_ACTIVE_STOPPED)
         {
             StreamStatus = StreamStatus.Stopped;
         }
         OnPropertyChanged("StreamStatus");
     }
 }
Exemplo n.º 8
0
        private void LvAudios_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Enter:
                Playfile();
                break;

            case Keys.Shift | Keys.Enter:
                if (lvAudios.SelectedItems.Count == 0)
                {
                    return;
                }
                if (tvSections.SelectedNode != tvSections.Nodes[1] && tvSections.SelectedNode.Parent != tvSections.Nodes[1])
                {
                    cmAudiosAdd.PerformClick();
                }
                break;

            case Keys.Delete:
                if (tvSections.SelectedNode == tvSections.Nodes[1] || tvSections.SelectedNode.Parent == tvSections.Nodes[1])
                {
                    cmAudiosDelete.PerformClick();
                }
                break;

            case Keys.Control | Keys.Shift | Keys.Alt | Keys.Return:
                cmAudiosDownload.PerformClick();
                break;

            case Keys.F2:
                if (tvSections.SelectedNode == tvSections.Nodes[1] || tvSections.SelectedNode.Parent == tvSections.Nodes[1])
                {
                    AudioEditAsync();
                }
                break;

            case Keys.Space:
            case Keys.MediaPlayPause:
                BASSActive isActive = default(BASSActive);
                isActive = Bass.BASS_ChannelIsActive(stream);
                if (isActive == BASSActive.BASS_ACTIVE_PLAYING)
                {
                    Bass.BASS_ChannelPause(stream);
                }
                else if (isActive == BASSActive.BASS_ACTIVE_PAUSED)
                {
                    Bass.BASS_ChannelPlay(stream, false);
                }
                e.Handled = e.SuppressKeyPress = true;
                break;
            }
        }
Exemplo n.º 9
0
        void Play()
        {
            BASSActive status = AudioControllerService.Current.GetStreamStatus();

            if (SelectedTracks.Count() > 0 && status == BASSActive.BASS_ACTIVE_STOPPED)
            {
                TracklistProvider.Instance.SetCurrentIndex(Tracks.IndexOf(SelectedTracks.First()));
                AudioControllerService.Current.LoadFile(TracklistProvider.Instance.GetCurrentTrack().Location);
            }
            else
            {
                switch (status)
                {
                case BASSActive.BASS_ACTIVE_PLAYING:

                    AudioControllerService.Current.Pause();

                    break;

                case BASSActive.BASS_ACTIVE_PAUSED:

                    AudioControllerService.Current.Play(false);

                    break;

                default:

                    if (TracklistProvider.Instance.Tracks.Count > 0)
                    {
                        if (TracklistProvider.Instance.CurrentIndex < 0)
                        {
                            TracklistProvider.Instance.SetCurrentIndex(0);
                        }
                        AudioControllerService.Current.LoadFile(TracklistProvider.Instance.GetCurrentTrack().Location);
                    }

                    break;
                }

                if (status != BASSActive.BASS_ACTIVE_PLAYING && TracklistProvider.Instance.Tracks.Count == 0)
                {
                    AddTrack();

                    if (TracklistProvider.Instance.Tracks.Count > 0)
                    {
                        TracklistProvider.Instance.SetCurrentIndex(0);
                        AudioControllerService.Current.LoadFile(TracklistProvider.Instance.GetCurrentTrack().Location);
                        //AudioControllerService.Instance.Play(false);
                    }
                }
            }
        }
Exemplo n.º 10
0
        private async void lstResults_KeyDownAsync(object sender, KeyEventArgs e)
        {
            switch (e.KeyData)
            {
            case Keys.Enter:
                if (lstResults.Items.Count == 0)
                {
                    return;
                }
                curIndex = lstResults.SelectedIndex;
                lstResults.SelectedIndex = curIndex;
                await PlayFileAsync(curIndex);

                break;

            case Keys.Space:
                BASSActive isActive = default(BASSActive);
                isActive = Bass.BASS_ChannelIsActive(stream);
                if (isActive == BASSActive.BASS_ACTIVE_PLAYING)
                {
                    Bass.BASS_ChannelPause(stream);
                    tmSeek.Enabled = false;
                }
                else if (isActive == BASSActive.BASS_ACTIVE_PAUSED)
                {
                    Bass.BASS_ChannelPlay(stream, false);
                    tmSeek.Enabled = true;
                }
                break;

            case Keys.Control | Keys.B:
                e.Handled = e.SuppressKeyPress = true;
                cmOpenInBrowser.PerformClick();
                break;

            case Keys.Control | Keys.C:
                e.Handled = e.SuppressKeyPress = true;
                cmCopyToClipboard.PerformClick();
                break;

            case Keys.Control | Keys.D:
                e.Handled = e.SuppressKeyPress = true;
                cmDownloadMp3.PerformClick();
                break;

            case Keys.Control | Keys.Q:
                e.Handled = e.SuppressKeyPress = true;
                mbExit.PerformClick();
                break;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 一時停止状態かどうか確認する
        /// </summary>
        /// <returns></returns>
        public bool isPasued()
        {
            bool paused = false;

            if (sound[PlayerController.MainChannel] != 0)
            {
                BASSActive status = Bass.BASS_ChannelIsActive(sound[PlayerController.MainChannel]);

                if (status == BASSActive.BASS_ACTIVE_PAUSED)
                {
                    paused = true;
                }
            }

            return(paused);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 再生中であるか確認する
        /// </summary>
        /// <returns></returns>
        public bool isPlaying(int channelNo)
        {
            bool playing = false;

            if (sound[channelNo] != 0)
            {
                BASSActive status = Bass.BASS_ChannelIsActive(sound[channelNo]);

                if (status == BASSActive.BASS_ACTIVE_PLAYING)
                {
                    playing = true;
                }
            }

            return(playing);
        }
Exemplo n.º 13
0
 private void PlayAndPauseExecute()
 {
     Status = Bass.BASS_ChannelIsActive(Config.Stream);
     if (Status == BASSActive.BASS_ACTIVE_PLAYING)
     {
         Bass.BASS_ChannelPause(Config.Stream);
         Status = Bass.BASS_ChannelIsActive(Config.Stream);
         return;
     }
     if (Status == BASSActive.BASS_ACTIVE_PAUSED)
     {
         Bass.BASS_ChannelPlay(Config.Stream, false);
         Status = Bass.BASS_ChannelIsActive(Config.Stream);
         return;
     }
 }
Exemplo n.º 14
0
        private void Instance_IndexChanged(int index)
        {
            BASSActive status = AudioControllerService.Current.GetStreamStatus();

            if (TracklistProvider.Instance.CurrentIndex == TracklistProvider.NO_TRACK_SELECTED_INDEX &&
                status == BASSActive.BASS_ACTIVE_PLAYING ||
                status == BASSActive.BASS_ACTIVE_PAUSED)
            {
                AudioControllerService.Current.Stop();
            }

            foreach (PluginVM item in Plugins)
            {
                item.Plugin.CurrentTrackIndexChanged(index);
            }
        }
Exemplo n.º 15
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == 0x0312)
            {
                int id = m.WParam.ToInt32();
                // MessageBox.Show(string.Format("Hotkey #{0} pressed", id));
                switch (id)
                {
                case 1:
                    if (lstResults.Items.Count == 0 || curIndex == 0)
                    {
                        return;
                    }
                    curIndex -= 1;
                    lstResults.SelectedIndex = curIndex;
                    PlayFileAsync(curIndex);
                    break;

                case 2:
                    if (lstResults.Items.Count == 0 || curIndex + 1 == lstResults.Items.Count)
                    {
                        return;
                    }
                    curIndex += 1;
                    lstResults.SelectedIndex = curIndex;
                    PlayFileAsync(curIndex);
                    break;

                case 3:
                    BASSActive isActive = default(BASSActive);
                    isActive = Bass.BASS_ChannelIsActive(stream);
                    if (isActive == BASSActive.BASS_ACTIVE_PLAYING)
                    {
                        Bass.BASS_ChannelPause(stream);
                        tmSeek.Enabled = false;
                    }
                    else if (isActive == BASSActive.BASS_ACTIVE_PAUSED)
                    {
                        Bass.BASS_ChannelPlay(stream, false);
                        tmSeek.Enabled = true;
                    }
                    break;
                }
            }

            base.WndProc(ref m);
        }
Exemplo n.º 16
0
    // Update is called once per frame
    void Update()
    {
        if (1 == 1)                                                                          //bassThreadRunning == true)
        {
            Bass.BASS_ChannelGetData(bassChannel, bassData, (int)BASSData.BASS_DATA_FFT256); // -2147483648);	// last param is magic number for FFT256, BassData won't let you convert?
            bassDataSum   = 0;
            bassFFTBass   = 0;
            bassFFTMid    = 0;
            bassFFTTreble = 0;
            for (int i = 0; i < bassDataSize; i++)
            {
                bassDataSum += bassData[i];
                if (i < 25)
                {
                    bassFFTBass += bassData[i];
                    bassFFTMid  += bassData[i] * 0.1f;
                }
                else if (i > 45)
                {
                    bassFFTTreble += bassData[i];
                    bassFFTMid    += bassData[i] * 0.1f;
                }
                else
                {
                    bassFFTMid += bassData[i] * 2.0f;
                }
            }

            //bassFFTBass += 1376256;
            //bassFFTBass *= 0.000000000003f;
            //bassFFTTreble += 1376256;
            //bassFFTTreble *= 0.000000000003f;
            //bassFFTMid += 1376256;
            //bassFFTMid *= 0.000000000003f;
            //Debug.Log("SUM: "+bassDataSum.ToString()+" DATA[0]: " + bassData[0].ToString() + " DATA[1]: " + bassData[1].ToString() + " DATA[2]: " + bassData[2].ToString());
        }

        bassActive = Bass.BASS_ChannelIsActive(bassChannel);
        if (bassActive == BASSActive.BASS_ACTIVE_STOPPED)
        {
            PlayStreamInThread(0);
        }
    }
Exemplo n.º 17
0
        public void PlaySound(string filename)
        {
            Bass.BASS_StreamFree(stream);
            syncCallback = new SYNCPROC(OnSongFinished);
            BASSActive isActive = default(BASSActive);

            isActive = Bass.BASS_ChannelIsActive(stream);
            if (isActive == BASSActive.BASS_ACTIVE_PLAYING)
            {
                Bass.BASS_ChannelStop(stream);
            }
            stream = Bass.BASS_StreamCreateURL(filename, 0, 0, null, IntPtr.Zero);
            Bass.BASS_ChannelSetAttribute(stream, BASSAttribute.BASS_ATTRIB_VOL, tbVolume.Value / 100F);
            Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END, 0, syncCallback, IntPtr.Zero);
            //Bass.BASS_Init(deviceIndex, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            Bass.BASS_SetDevice(deviceIndex);
            Bass.BASS_ChannelSetDevice(stream, deviceIndex);
            Bass.BASS_ChannelPlay(stream, false);
        }
Exemplo n.º 18
0
        void Play()
        {
            BASSActive status = AudioControllerService.Current.GetStreamStatus();

            switch (status)
            {
            case BASSActive.BASS_ACTIVE_PLAYING:

                AudioControllerService.Current.Pause();

                break;

            case BASSActive.BASS_ACTIVE_PAUSED:

                AudioControllerService.Current.Play(false);

                break;

            default:

                if (TracklistProvider.Instance.Tracks.Count > 0)
                {
                    if (TracklistProvider.Instance.CurrentIndex < 0)
                    {
                        TracklistProvider.Instance.SetCurrentIndex(0);
                        //MessengerProvider.Instance.NotifyColleagues(MessengerNSR.TRACKLIST_INDEX_CHANGED, currentIndex);
                    }
                    //AudioControllerService.Instance.Play(true);
                    AudioControllerService.Current.LoadFile(TracklistProvider.Instance.GetCurrentTrack().Location);
                }

                break;
            }

            status = AudioControllerService.Current.GetStreamStatus();

            if (status != BASSActive.BASS_ACTIVE_PLAYING && TracklistProvider.Instance.Tracks.Count == 0)
            {
                OpenFile();
            }
        }
Exemplo n.º 19
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            BASSActive status = (BASSActive)value;
            string     result = "\ue74f";

            switch (status.ToString())
            {
            case "BASS_ACTIVE_STOPPED":
                result = "\ue74f";
                break;

            case "BASS_ACTIVE_PAUSED":
                result = "\ue74f";
                break;

            case "BASS_ACTIVE_PLAYING":
                result = "\ue76a";
                break;
            }
            return(result);
        }
Exemplo n.º 20
0
        /***************  Ctrl  ************************/
        public void Play()
        {
            if (CurrentMusicHandle == 0)
            {
                Debug.LogError("No music loading");
                return;
            }
            BASSActive bASSActive = Bass.BASS_ChannelIsActive(CurrentMusicHandle);

            if (bASSActive == BASSActive.BASS_ACTIVE_PAUSED) //如果暂停了,重新播放
            {
                Bass.BASS_ChannelPlay(CurrentMusicHandle, false);
            }
            else  //否则重头开始播放
            {
                //预缓冲
                Bass.BASS_ChannelUpdate(CurrentMusicHandle, 0);
                //播放 是否重新开始
                Bass.BASS_ChannelPlay(CurrentMusicHandle, true);
            }
        }
Exemplo n.º 21
0
        private void Instance_StatusChanged(BASSActive status)
        {
            switch (status)
            {
            case BASSActive.BASS_ACTIVE_PAUSED:
                PlayerStatus = PLAYER_STATUS.PAUSED;
                break;

            case BASSActive.BASS_ACTIVE_PLAYING:
                PlayerStatus = PLAYER_STATUS.PLAYING;
                break;

            case BASSActive.BASS_ACTIVE_STALLED:
                PlayerStatus = PLAYER_STATUS.STALLED;
                break;

            case BASSActive.BASS_ACTIVE_STOPPED:
                PlayerStatus = PLAYER_STATUS.STOPPED;
                break;
            }
        }
Exemplo n.º 22
0
        public YingMediaPage(String yurl, Action yended)
        {
            InitializeComponent();

            yelement.Source = new Uri(yurl);
            yelement.Play();
            yelement.MediaOpened += (ysender, yevent) =>
            {
                yelement.Position = new TimeSpan(20020);
                BASSActive y = getYPlayer().isYActive();
                if (getYPlayer().isYActive() == BASSActive.BASS_ACTIVE_PLAYING)
                {
                    this.isY = true;
                    getYPlayer().YPause();
                }
            };
            yelement.MediaEnded += (ysender, yevent) =>
            {
                if (this.isY)
                {
                    getYPlayer().YPlay();
                }
                yended.Invoke();
                yelement.Close();
            };

            //if (yallowback) ybackButton.Visibility = Visibility.Visible;
            yelement.MouseLeftButtonDown += (y, yy) =>
            {
                if (this.isY)
                {
                    getYPlayer().YPlay();
                }
                yended.Invoke();
                yelement.Close();
            };
        }
Exemplo n.º 23
0
 private void OnPlay(object sender, EventArgs e)
 {
     _status = Bass.BASS_ChannelIsActive(stream);
     if (_status == BASSActive.BASS_ACTIVE_STOPPED)
     {
         foreach (ToolStripMenuItem item in stations.DropDownItems)
         {
             foreach (ToolStripMenuItem tmp in item.DropDownItems)
             {
                 if (tmp.Text == lastStation)
                 {
                     tmp.PerformClick();
                     break;
                 }
             }
         }
         if (enableSleepTimer.Checked == true)
         {
             timeX.Start();
         }
     }
     else if (_status == BASSActive.BASS_ACTIVE_PAUSED)
     {
         if (enableSleepTimer.Checked == true)
         {
             timeX.Start();
         }
         Bass.BASS_ChannelPlay(stream, true);
         Fixes.Fixes.SetNotifyIconText(trayIcon, GetTooltipText(_tagInfo.artist + "\r\n" + _tagInfo.title + "\r\n" + stationTitle));
         trayIcon.Icon = Properties.Resources.icons8_radio_tower1;
     }
     play.Visible     = false;
     pause.Visible    = true;
     stop.Enabled     = true;
     next.Enabled     = true;
     previous.Enabled = true;
 }
Exemplo n.º 24
0
        // the main ASIO callback - filling the ASIO buffer with sample data to play...
        private int AsioCallback(bool input, int channel, IntPtr buffer, int length, IntPtr user)
        {
            // Note: 'user' contains the underlying stream channel (_streamFX)

            // get the status of the playing channel...(Note: you can do this also with a SYNCPORC)!
            _status = Bass.BASS_ChannelIsActive(user.ToInt32());
            // now we evaluate the status...
            if (_status == BASSActive.BASS_ACTIVE_STOPPED)
            {
                // if the playing channel is at the end, we pause ASIO
                // Note: you need to call BASS_ASIO_ChannelReset to resume the ASIO channel!
                BassAsio.BASS_ASIO_ChannelPause(false, channel);

                this.BeginInvoke(new UpdateMessageDelegate(UpdateMessageDisplay), new object[] { "stopped" });
                return(0);
            }
            else if (_status == BASSActive.BASS_ACTIVE_PAUSED || _status == BASSActive.BASS_ACTIVE_STALLED)
            {
                this.BeginInvoke(new UpdateMessageDelegate(UpdateMessageDisplay), new object[] { "paused" });
                return(0);
            }
            else
            {
                // if playing, we just get the data from our decoding channel
                // Note: a decoding channel will be 'advanced' automatically,
                // so the next call to the decoding channel will get the next data...
                _decLength = Bass.BASS_ChannelGetData(user.ToInt32(), buffer, length);

                // however, it might be the case, that BASS_ChannelGetData returned less data than requested
                if (_decLength < 0)
                {
                    _decLength = 0;
                }
            }

            // from here on we deal with our buffer...calculating the peak VU
            int l4 = _decLength / 4;

            _maxL = 0;
            _maxR = 0;
            unsafe
            {
                float *data = (float *)buffer;
                for (a = 0; a < l4; a++)
                {
                    // decide on L/R channel
                    if (a % 2 == 0)
                    {
                        // L channel
                        if (data[a] > _maxL)
                        {
                            _maxL = data[a];
                        }
                    }
                    else
                    {
                        // R channel
                        if (data[a] > _maxR)
                        {
                            _maxR = data[a];
                        }
                    }
                }
            }
            // limit the maximum peak levels to 0bB = 32768
            // and a float value of 1.0 also represents 0db.
            _peakL = (int)Math.Round(32768f * _maxL);
            if (_peakL > 32768)
            {
                _peakL = 32768;
            }
            _peakR = (int)Math.Round(32768f * _maxR);
            if (_peakR > 32768)
            {
                _peakR = 32768;
            }

            return(_decLength);
        }
Exemplo n.º 25
0
        public Player(int deviceNumber)
        {
            _playlist = new Playlist(this);

            InitBassLibrary(deviceNumber);

            _timer          = new System.Timers.Timer(100);
            _timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);

            _meta_proc = new SYNCPROC(meta_sync);

            void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                BASSActive active = Bass.BASS_ChannelIsActive(_stream);

                if (active == BASSActive.BASS_ACTIVE_PLAYING)
                {
                    _position = Bass.BASS_ChannelBytes2Seconds(_stream, Bass.BASS_ChannelGetPosition(_stream));
                    PositionChanged(this, EventArgs.Empty);

                    if (Convert.ToInt32(_lastPosition) != Convert.ToInt32(_position))
                    {
                        OnPositionDescriptionChanged();
                        _lastPosition = _position;
                    }

                    _timerTicks += 100;
                    if (_timerTicks >= 1000)
                    {
                        _timerTicks = 0;
                        _secondsPlayed++;
                        if (_secondsPlayed >= SecondsBeforeUpdatePlayCount && !_playCountUpdated)
                        {
                            System.Diagnostics.Debug.WriteLine(SecondsBeforeUpdatePlayCount.ToString() + " seconds, updating play count");

                            _playCountUpdated = true;
                            if (_lib != null)
                            {
                                _lib.UpdatePlayCount(_currentSong.FileName);
                                if (AudioscrobblerEnabled)
                                {
                                    var req = new AudioscrobblerRequest();
                                    req.Username = AudioscrobblerUserName;
                                    req.Password = AudioscrobblerPassword;
                                    req.SubmitTrack(_currentSong);
                                }
                            }
                        }
                    }
                }
                else if (active == (int)BASSActive.BASS_ACTIVE_STOPPED)
                {
                    if (!_playCountUpdated)
                    {
                        if (Convert.ToInt32(this.CurrentSong.Duration) <= SecondsBeforeUpdatePlayCount)
                        {
                            System.Diagnostics.Debug.WriteLine("Didn't reach " + SecondsBeforeUpdatePlayCount.ToString() + " seconds because song finished, updating play count");

                            _playCountUpdated = true;
                            if (_lib != null)
                            {
                                _lib.UpdatePlayCount(_currentSong.FileName);
                            }
                        }
                    }
                    _timer.Stop();
                    this.State = PlayerState.Stopped;
                    OnSongFinished();
                    if (_autoTrackAdvance)
                    {
                        if (_repeatCurrentTrack)
                        {
                            Stop();
                            Play();
                        }
                        else
                        {
                            Next();
                        }
                    }
                }
            }
        }
Exemplo n.º 26
0
        private void FormNotifyMenucs_Load(object sender, EventArgs e)
        {
            pl_base.BackColor      = Color.White;
            btn_playpause.Location = new Point(90, 20);
            btn_up.Location        = new Point(30, 25);
            btn_next.Location      = new Point(150, 25);
            btn_volzh.Location     = new Point(16, 100);
            lb_text.Size           = new Size(215, 15);
            lb_text.Location       = new Point(1, 70);
            lb_text.TextRenderMode = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            lb_text.Font           = new Font("微软雅黑", 9f);
            lb_text.ForeColor      = Color.FromArgb(102, 102, 102);
            lb_text.TextAlign      = ContentAlignment.MiddleCenter;
            lb_text.Text           = "迷你音乐,音乐我的生活!";
            i_exit.Location        = new Point(5, 242);
            sp.Location            = new Point(1, 235);
            sp.Size                       = new Size(Width - 1, 1);
            sp.BackColor                  = Color.FromArgb(230, 230, 230);
            sp2.Location                  = new Point(1, 194);
            sp2.Size                      = new Size(Width - 1, 1);
            sp2.BackColor                 = Color.FromArgb(230, 230, 230);
            sp3.Location                  = new Point(1, 124);
            sp3.Size                      = new Size(Width - 1, 1);
            sp3.BackColor                 = Color.FromArgb(230, 230, 230);
            i_locklrc.Location            = new Point(5, 160);
            i_showlrc.Location            = new Point(5, 130);
            i_setting.Location            = new Point(5, 198);
            i_exit.Text                   = "退出";
            i_setting.Text                = "设置";
            i_setting.NormalImage         = Properties.Resources.i_setting_n;
            i_setting.HoverImage          = Properties.Resources.i_setting_h;
            i_setting.DisableImage        = Properties.Resources.i_setting_d;
            i_locklrc.Text                = "锁定歌词";
            i_locklrc.Enabled             = false;
            i_locklrc.NormalImage         = Properties.Resources.i_locklrc_n;
            i_locklrc.HoverImage          = Properties.Resources.i_locklrc_h;
            i_locklrc.DisableImage        = Properties.Resources.i_locklrc_d;
            i_showlrc.Text                = "显示歌词";//230
            i_showlrc.NormalImage         = Properties.Resources.i_lrc_n;
            i_showlrc.HoverImage          = Properties.Resources.i_lrc_h;
            i_showlrc.DisableImage        = Properties.Resources.i_lrc_d;
            btn_playpause.CheckedNorImg   = Properties.Resources.i_btn_pause_n_;
            btn_playpause.CheckedHovImg   = Properties.Resources.i_btn_pause_h;
            btn_playpause.CheckedPreImg   = Properties.Resources.i_btn_pause_p;
            btn_playpause.UnCheckedNorImg = Properties.Resources.i_btn_play_n;
            btn_playpause.UnCheckedHovImg = Properties.Resources.i_btn_play_h;
            btn_playpause.UnCheckedPreImg = Properties.Resources.i_btn_play_p;
            btn_up.NormalImage            = Properties.Resources.i_up_n;
            btn_up.HoverImage             = Properties.Resources.i_up_h;
            btn_up.PressedImage           = Properties.Resources.i_up_p;
            btn_next.NormalImage          = Properties.Resources.i_next_n;
            btn_next.HoverImage           = Properties.Resources.i_next_h;
            btn_next.PressedImage         = Properties.Resources.i_next_p;
            btn_volzh.CheckedNorImg       = Properties.Resources.i_sound_dis_n;
            btn_volzh.CheckedHovImg       = Properties.Resources.i_sound_dis_h;
            btn_volzh.CheckedPreImg       = Properties.Resources.i_sound_dis_p;
            btn_volzh.UnCheckedNorImg     = Properties.Resources.i_sound_n;
            btn_volzh.UnCheckedHovImg     = Properties.Resources.i_sound_h;
            btn_volzh.UnCheckedPreImg     = Properties.Resources.i_sound_p;
            btn_volzh.CheckOnClick        = true;

            i_exit.MouseClick        += I_exit_MouseClick;
            i_setting.MouseClick     += I_setting_MouseClick;
            btn_playpause.MouseClick += Btn_playpause_MouseClick;
            btn_volzh.MouseClick     += Btn_volzh_MouseClick;
            btn_next.MouseClick      += Btn_next_MouseClick;
            btn_up.MouseClick        += Btn_up_MouseClick;

            pl_base.DUIControls.Add(i_exit);
            pl_base.DUIControls.Add(i_setting);
            pl_base.DUIControls.Add(i_locklrc);
            pl_base.DUIControls.Add(i_showlrc);
            pl_base.DUIControls.Add(sp);
            pl_base.DUIControls.Add(sp2);
            pl_base.DUIControls.Add(sp3);
            pl_base.DUIControls.Add(lb_text);
            pl_base.DUIControls.Add(btn_playpause);
            pl_base.DUIControls.Add(btn_next);
            pl_base.DUIControls.Add(btn_up);
            pl_base.DUIControls.Add(btn_volzh);

            BASSActive b = Bass.BASS_ChannelIsActive(m.stream);

            if (b == BASSActive.BASS_ACTIVE_PLAYING)
            {
                btn_playpause.Checked = true;
            }
            else
            {
                btn_playpause.Checked = false;
            }

            if (m.Volume == 0)
            {
                btn_volzh.Checked      = true;
                layeredTrackBar1.Value = 0;
            }
            else
            {
                btn_volzh.Checked      = false;
                layeredTrackBar1.Value = (double)m.Volume / 100;
            }
            a();
        }
Exemplo n.º 27
0
        protected override void OnLoad(EventArgs e)
        {
            Visible       = false;
            ShowInTaskbar = false;

            hooker.Add("Toggle Play", Keys.MediaPlayPause);
            hooker.Add("Stop", Keys.MediaStop);

            if (stationSwitcher.Checked == true)
            {
                hooker.Add("Next Station", Keys.MediaNextTrack);
                hooker.Add("Previous Station", Keys.MediaPreviousTrack);
            }

            hooker.HotkeyDown += (sender, q) => {
                switch (q.Name)
                {
                case "Toggle Play":
                    _status = Bass.BASS_ChannelIsActive(stream);
                    Console.WriteLine(_status);
                    if (_status == BASSActive.BASS_ACTIVE_STOPPED || _status == BASSActive.BASS_ACTIVE_PAUSED)
                    {
                        play.PerformClick();
                    }
                    else if (_status == BASSActive.BASS_ACTIVE_PLAYING)
                    {
                        pause.PerformClick();
                    }
                    break;

                case "Stop":
                    stop.PerformClick();
                    break;

                case "Previous Station":
                    previous.PerformClick();
                    break;

                case "Next Station":
                    next.PerformClick();
                    break;
                }
            };

            if (enableMMKeys.Checked == true)
            {
                hooker.Hook();
            }
            else
            {
                if (hooker.IsHooked)
                {
                    hooker.Unhook();
                }
            }

            XmlDocument prefs = new XmlDocument();

            prefs.Load(path + "\\preferences.xml");
            XmlNode prefsRoot = prefs.FirstChild;

            if (prefsRoot["autoplay"].InnerText == "true")
            {
                foreach (ToolStripMenuItem item in stations.DropDownItems)
                {
                    foreach (ToolStripMenuItem tmp in item.DropDownItems)
                    {
                        if (tmp.Text == prefsRoot["lastStation"].InnerText)
                        {
                            tmp.PerformClick();
                            break;
                        }
                    }
                }
            }

            base.OnLoad(e);
        }
Exemplo n.º 28
0
        protected override void OnStartup(StartupEventArgs e)
        {
            _mutex = new Mutex(false, Current.ToString());
            if (_mutex.WaitOne(500, false))
            {
                if ((_isInitialised = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero)))
                {
                    _trayIcon             = new NotifyIcon();
                    _trayIcon.MouseClick += (object sender, MouseEventArgs args) =>
                    {
                        if (args.Button == MouseButtons.Left)
                        {
                            if (_balanceVolumeWnd == null)
                            {
                                _balanceVolumeWnd         = new BalanceVolumeWindow();
                                _balanceVolumeWnd.Closed += (object sender2, EventArgs args2) => { _balanceVolumeWnd = null; };
                                _balanceVolumeWnd.Show();
                            }
                            else if (_balanceVolumeWnd.IsVisible)
                            {
                                _balanceVolumeWnd.Hide();
                            }
                            else
                            {
                                _balanceVolumeWnd.Show();
                            }
                        }
                    };
                    _trayIcon.Icon    = IconAntennaNoSignal;
                    _trayIcon.Text    = InfovojnaRadio.Properties.Resources.InfovojnaRadio;
                    _trayIcon.Visible = true;
                    CreateRadioMenu();
                    Task.Factory.StartNew((Action)(() =>
                    {
                        do
                        {
                            if (ActiveRadio != null)
                            {
                                BASSActive status = ActiveRadio.Status;
                                switch (status)
                                {
                                case BASSActive.BASS_ACTIVE_PLAYING:
                                    _trayIcon.ContextMenu.MenuItems[0].Enabled = true;
                                    _trayIcon.Icon = IconAntennaSignal;
                                    string text = string.Format("{0} - {1}", (object)InfovojnaRadio.Properties.Resources.InfovojnaRadio, ActiveRadio.Name);
                                    _trayIcon.Text = text.Length >= 60 ? text.Substring(0, 60) + "..." : text;
                                    if (ActiveRadio.IsNewSong || (status != _radioStatus))
                                    {
                                        ShowBallonTip(string.Format("{0} - Prehráva sa\n\n{1}", ActiveRadio.Name, ActiveRadio.Info.Title), ToolTipIcon.Info);
                                    }
                                    break;

                                case BASSActive.BASS_ACTIVE_STALLED:
                                    _trayIcon.Icon = IconAntennaSignalStalled;
                                    if (status != _radioStatus)
                                    {
                                        ShowBallonTip(string.Format("{0} - Zastavené", ActiveRadio.Name), ToolTipIcon.Warning);                                                //stalled
                                    }
                                    break;

                                default:
                                    _trayIcon.ContextMenu.MenuItems[0].Enabled = false;
                                    _trayIcon.Icon = IconAntennaNoSignal;
                                    _trayIcon.Text = InfovojnaRadio.Properties.Resources.InfovojnaRadio;
                                    if (status != _radioStatus)
                                    {
                                        ShowBallonTip(string.Format("{0} - Zastavené", ActiveRadio.Name), ToolTipIcon.Info);                                                //stopped
                                    }
                                    break;
                                }
                                _radioStatus = status;
                            }
                            Thread.Sleep(1);
                        } while (!_cts.IsCancellationRequested);
                    }));
                    // Autoplay...
                    if (InfovojnaRadio.Properties.Settings.Default.AutoplayRadio)
                    {
                        (ActiveRadio = InfovojnaRadio.Properties.Settings.Default.Radios[InfovojnaRadio.Properties.Settings.Default.AutoplayRadioName]).Play();
                    }
                    base.OnStartup(e);
                }
                else
                {
                    Shutdown(-1);
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Program Infovojna-radio je už spustený.", InfovojnaRadio.Properties.Resources.InfovojnaRadio, MessageBoxButton.OK, MessageBoxImage.Warning);
                Shutdown(0);
            }
        }