예제 #1
0
        public Player()
            : base()
        {
            LoadSettings();
            UserAssistant           = new UserAssistant();
            UserAssistant.Settings  = Settings;
            ChannelSearch           = new ChannelSearch(Settings);
            DownloadSearch.Settings = Settings;

            //加红心功能始终启用
            IsLikedEnabled = true;

            //歌曲改变时更新红心状态
            CurrentSongChanged += new EventHandler((o, e) =>
            {
                if (CurrentSong != null)
                {
                    IsLiked = CurrentSong.Like;
                }
            });

            UserAssistant.CurrentStateChanged += (o, e) =>
            {
                //更新IsNeverEnabled
                IsNeverEnabled = UserAssistant.CurrentState == UserAssistant.State.LoggedOn || UserAssistant.CurrentState == UserAssistant.State.LoggingOff;
                switch ((UserAssistant.State)e.NewValue)
                {
                case UserAssistant.State.LoggedOn:
                    RaisePlayRecordChangedEvent();
                    break;

                case UserAssistant.State.LoggedOff:
                    if (CurrentChannel != null && CurrentChannel.IsPersonal && !CurrentChannel.IsSpecial)
                    {
                        CurrentChannel = ChannelInfo.Public.First();
                    }
                    break;
                }
            };

            //获取播放列表失败后引发事件
            PlayList.GetPlayListFailed += (o, e) => Dispatcher.Invoke(new Action(() => RaiseGetPlayListFailedEvent(e)));
        }
예제 #2
0
		public Player()
			: base()
		{
			LoadSettings();
			UserAssistant = new UserAssistant();
			UserAssistant.Settings = Settings;
			ChannelSearch = new ChannelSearch(Settings);
			DownloadSearch.Settings = Settings;

            //加红心功能始终启用
		    IsLikedEnabled = true;

			//歌曲改变时更新红心状态
			CurrentSongChanged += new EventHandler((o, e) =>
			{
				if (CurrentSong != null)
				{
					IsLiked = CurrentSong.Like;
				}
			});

            UserAssistant.CurrentStateChanged += (o, e) =>
                {
                    //更新IsNeverEnabled
                    IsNeverEnabled = UserAssistant.CurrentState == UserAssistant.State.LoggedOn || UserAssistant.CurrentState == UserAssistant.State.LoggingOff;
                    switch ((UserAssistant.State) e.NewValue)
                    {
                        case UserAssistant.State.LoggedOn:
                            RaisePlayRecordChangedEvent();
                            break;
                        case UserAssistant.State.LoggedOff:
                            if (CurrentChannel != null && CurrentChannel.IsPersonal && !CurrentChannel.IsSpecial)
                                CurrentChannel = ChannelInfo.Public.First();
                            break;
                    }
                };

			//获取播放列表失败后引发事件
			PlayList.GetPlayListFailed += (o, e) => Dispatcher.Invoke(new Action(() => RaiseGetPlayListFailedEvent(e)));
		}