/// <summary> /// 更改音乐播放状态 /// </summary> /// <param name="musicViewModel"></param> /// <param name="tb"></param> private void ChangeMusicPlayState(QMInfoViewModel musicViewModel, TextBlock tb) { if (musicViewModel != null) { _nextPlayingTbObject = new KeyValuePair <string, TextBlock>(musicViewModel.Id, tb); var isToPlay = true; if (tb != null) { isToPlay = !tb.Text.Equals("\ue69d"); } Task.Factory.StartNew(() => { var htmlWeb = new HtmlWeb() { BrowserTimeout = TimeSpan.FromSeconds(10) }; var doc = htmlWeb.Load(musicViewModel.SourcePath); var photoUrl = doc.DocumentNode.SelectNodes("//img[@class='data__photo']")?.FirstOrDefault()?.Attributes["src"].Value?.ToHttpUrl(); var musicInfo = new QMPlayInfoModel() { Id = musicViewModel.Id, Name = musicViewModel.Name, SingerName = musicViewModel.SingerName, TimeDuration = musicViewModel.TimeDuration, Uri = new Uri($"http://thirdparty.gtimg.com/C100{musicViewModel.Id}.m4a?fromtag=38", UriKind.Absolute), PhotoUri = photoUrl == null ? null : new Uri(photoUrl) }; MusicPlayStateChangedUtil.InvokeFromQM(musicInfo, isToPlay); }); } }
/// <summary> /// 更改激活状态 /// </summary> /// <param name="lvi"></param> private void ChangeMusicActivatedState(QMInfoViewModel item) { RemoveCurrentPlayingMusicActivatedState(); if (item != null) { item.IsActivated = true; } }