コード例 #1
0
 public DefSongList(Song song)
 {
     InitializeComponent();
     this.song = song;
     this.songName.Content = song.title;
     this.singerAlbumName.Content = string.Format("{0} <{1}>", song.artist, song.albumtitle);
     this.albumPic.Source = new BitmapImage(new Uri(song.picture, UriKind.RelativeOrAbsolute));
     songRow.MouseEnter += delegate
     {
         if (isPlaying)
             return;
         removeSong.Visibility = Visibility.Visible;
         this.Background = new SolidColorBrush(Color.FromRgb(224, 232, 190));
     };
     songRow.MouseLeave += delegate
     {
         if (isPlaying)
             return;
         removeSong.Visibility = Visibility.Collapsed;
         this.Background = new SolidColorBrush(Colors.Transparent);
     };
 }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: justplus/doubanFM1
        private void SetPlayer(Song song)
        {
            timer.Start();
            player.Source = new Uri(song.url, UriKind.Absolute);
            player.Play();
            playerSongName.Content = song.title;
            playerAlbum.Source = new BitmapImage(new Uri(song.picture, UriKind.Absolute));
            playerSingerAlbum.Content = string.Format("{0} <{1}>", song.artist, song.albumtitle);
            playerLike.Source = (song.like == "1") ? new BitmapImage(new Uri("Images/RedHeart.png", UriKind.RelativeOrAbsolute)) : new BitmapImage(new Uri("Images/Heart.png", UriKind.RelativeOrAbsolute));
            playerLike.Tag = (song.like == "1") ? "Like" : "Unlike";
            songControl.currentSongIdx = songControl.currentQueue.IndexOf(song);
            getSongLyric(song);
            DefSongList dsl = songListCanvas.Children[songControl.currentSongIdx] as DefSongList;
            foreach (DefSongList tmp in songListCanvas.Children)
            {
                tmp.Background = new SolidColorBrush(Colors.Transparent);
                tmp.isPlaying = false;
            }
            dsl.Background = new SolidColorBrush(Color.FromRgb(224,232,190));
            dsl.isPlaying = true;
            int length = (int)(Double.Parse(song.length));
            timer.Tick += delegate
            {
                TimeSpan AfterSpan = player.Position;
                playerSongTime.Content = string.Format("{0:D2}:{1:D2}/{2:D2}:{3:D2}", AfterSpan.Minutes, AfterSpan.Seconds, length / 60, length - length / 60 * 60);
                playerProgress.Value = AfterSpan.TotalSeconds / length * 100;

                //设置歌词
                lyric.Refresh(AfterSpan);
                lyricWindow.lyric1.Content = lyric.lyric1;
                lyricWindow.lyric2.Content = lyric.lyric2;
                lyricWindow.lyric3.Content = lyric.lyric3;
            };
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: justplus/doubanFM1
 //异步加载歌词
 private async void getSongLyric(Song song)
 {
     await Task.Run(() =>
         {
             lyric = new LyricMV();
             string keyword = string.Empty;
             if (song.title.Contains("("))
                 keyword += song.title.Substring(0, song.title.IndexOf("("));
             else
                 keyword += song.title;
             keyword += @" ";
             keyword += song.artist;
             lyric.GetSongIds(keyword);
             if (lyric.songID.Count == 0)
                 return;
             lyric.LyricContent(lyric.songID[0]);
         });
 }