Пример #1
0
        private void bass_PlaybackStateChanged(object sender, BassAudioEngine.PlayState oldState,
            BassAudioEngine.PlayState newState)
        {
            if (PlaybackStateChanged != null) PlaybackStateChanged(this, oldState, newState);

            Log.O("Playstate: " + newState);

            Paused = newState == BassAudioEngine.PlayState.Paused;
            Playing = newState == BassAudioEngine.PlayState.Playing;
            Stopped = newState == BassAudioEngine.PlayState.Ended || newState == BassAudioEngine.PlayState.Stopped;

            if (Playing) _cqman.SendStatusUpdate(QueryStatusValue.Playing);
            else if (Paused) _cqman.SendStatusUpdate(QueryStatusValue.Paused);
            else if (Stopped) _cqman.SendStatusUpdate(QueryStatusValue.Stopped);

            if (newState == BassAudioEngine.PlayState.Ended && CurrentStation != null)
            {
                Log.O("Song ended, playing next song.");
                RunTask(() => PlayNextSong());
            }
        }
Пример #2
0
        private void _player_PlaybackStateChanged(object sender, BassAudioEngine.PlayState oldState,
                                                  BassAudioEngine.PlayState newState)
        {
            this.BeginDispatch(() =>
                                   {
                                       if (newState == BassAudioEngine.PlayState.Playing)
                                       {
                                           string title = "Elpis | " + _player.CurrentSong.Artist + " / " +
                                                          _player.CurrentSong.SongTitle;

                                           _notify.Text = title.StringEllipses(63);
                                               //notify text cannot be more than 63 chars
                                           Title = title;
                                       }
                                       else if (newState == BassAudioEngine.PlayState.Paused)
                                       {
                                           Title = _notify.Text = "Elpis";
                                       }
                                       else if (newState == BassAudioEngine.PlayState.Stopped)
                                       {
                                           mainBar.SetPlaying(false);
                                           Title = _notify.Text = "Elpis";
                                           if(_player.LoggedIn)
                                              ShowStationList();
                                       }
                                   });
        }
Пример #3
0
 private void bass_PlaybackProgress(object sender, BassAudioEngine.Progress prog)
 {
     if (PlaybackProgress != null) PlaybackProgress(this, prog);
     _cqman.SendProgressUpdate(_cqman.LastSong, prog.TotalTime, prog.ElapsedTime);
 }
Пример #4
0
        public bool Initialize(string bassRegEmail = "", string bassRegKey = "")
        {
            _cqman = new ControlQueryManager();
            _cqman.NextRequest += _cqman_NextRequest;
            _cqman.PauseRequest += _cqman_PauseRequest;
            _cqman.PlayRequest += _cqman_PlayRequest;
            _cqman.StopRequest += _cqman_StopRequest;
            _cqman.PlayStateRequest += _cqman_PlayStateRequest;
            _cqman.SetSongMetaRequest += _cqman_SetSongMetaRequest;

            _sessionWatcher = new SessionWatcher();
            RegisterPlayerControlQuery(_sessionWatcher);

            _pandora = new Pandora();
            _pandora.ConnectionEvent += _pandora_ConnectionEvent;
            _pandora.StationUpdateEvent += _pandora_StationUpdateEvent;
            _pandora.FeedbackUpdateEvent += _pandora_FeedbackUpdateEvent;
            _pandora.LoginStatusEvent += _pandora_LoginStatusEvent;
            _pandora.StationsUpdatingEvent += _pandora_StationsUpdatingEvent;
            _pandora.QuickMixSavedEvent += _pandora_QuickMixSavedEvent;

            _bass = new BassAudioEngine(bassRegEmail, bassRegKey);
            _bass.PlaybackProgress += bass_PlaybackProgress;
            _bass.PlaybackStateChanged += bass_PlaybackStateChanged;
            _bass.PlaybackStart += bass_PlaybackStart;
            _bass.PlaybackStop += bass_PlaybackStop;
            _bass.InitBass();

            _playlist = new Playlist();
            _playlist.MaxPlayed = 8;
            _playlist.PlaylistLow += _playlist_PlaylistLow;
            _playlist.PlayedSongQueued += _playlist_PlayedSongQueued;
            _playlist.PlayedSongDequeued += _playlist_PlayedSongDequeued;

            DailySkipLimitReached = false;
            DailySkipLimitTime = DateTime.MinValue;

            LoggedIn = false;
            return true;
        }
Пример #5
0
 private void _player_PlaybackStateChanged(object sender, BassAudioEngine.PlayState oldState,
     BassAudioEngine.PlayState newState)
 {
     lock (_currSongLock)
     {
         if (newState == BassAudioEngine.PlayState.Playing && _currSong != null)
             this.BeginDispatch(() => SetSong(_currSong));
     }
 }
Пример #6
0
 private void _player_PlaybackProgress(object sender, BassAudioEngine.Progress prog)
 {
     UpdateProgress(prog);
 }
Пример #7
0
 private void UpdateProgress(BassAudioEngine.Progress prog)
 {
     this.BeginDispatch(() =>
                            {
                                lblCurrTime.Content = prog.ElapsedTime.ToString(@"mm\:ss");
                                lblRemainTime.Content = prog.RemainingTime.ToString(@"mm\:ss");
                                progPlayTime.Value = prog.Percent;
                            });
 }