/// <summary> /// 开始播放 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void menu_Play_PreviewMouseDown(object sender, RoutedEventArgs e) { string url = music.GetMusicUrl(musicinfo[List.SelectedIndex].Api, musicinfo[List.SelectedIndex].Id); if (string.IsNullOrEmpty(url)) { AduMessageBox.Show("播放失败", "提示", MessageBoxButton.OK); return; } CurrentMusicLabel.Text = musicinfo[List.SelectedIndex].Title + " - " + musicinfo[List.SelectedIndex].Singer; playlist.Clear(); for (int i = 0; i < musicinfo.Count; i++) { CurrentMusicInfo cmi = new CurrentMusicInfo { Api = musicinfo[i].Api, Id = musicinfo[i].Id, Title = musicinfo[i].Title, Singer = musicinfo[i].Singer }; playlist.Add(cmi); } currentmusicindex = List.SelectedIndex; player.Open(new Uri(url)); player.Play(); timer.Elapsed += Timer_Elapsed; timer.Enabled = true; timer.AutoReset = true; isPlaying = true; CtrlButton.Text = "\xe61d"; }
private void finish_load_music(string url, string text, int move_music_index) { this.Dispatcher.Invoke(new Action(() => { player.Open(new Uri(url)); player.Play(); timer.Elapsed += Timer_Elapsed; timer.Enabled = true; timer.AutoReset = true; isPlaying = true; CtrlButton.Text = "\xe61d"; CurrentMusicLabel.Text = text; if (move_music_index == -1) { currentmusicindex--; } else if (move_music_index == -2) { currentmusicindex++; } else if (move_music_index >= 0) { playlist.Clear(); for (int i = 0; i < musicinfo.Count; i++) { CurrentMusicInfo cmi = new CurrentMusicInfo { Api = musicinfo[i].Api, Id = musicinfo[i].Id, Title = musicinfo[i].Title, Singer = musicinfo[i].Singer }; playlist.Add(cmi); } currentmusicindex = move_music_index; } LoadingState.Text = ""; })); }