예제 #1
0
 /// <summary>
 /// 异步获取播放列表
 /// </summary>
 private void getSongList(bool channelChanged = false, bool naturalEnd = false)
 {
     songControl.Next(channelChanged);
     if (!naturalEnd)
     {
         for (int i = 0; i < songControl.currentQueue.Count; i++)
         {
             DefSongList songList = new DefSongList(songControl.currentQueue[i]);
             songList.MouseDoubleClick += delegate
             {
                 songList.removeSong.Visibility = Visibility.Collapsed;
                 SetPlayer(songList.song);
             };
             songListCanvas.Children.Add(songList);
         }
         SetPlayer(songControl.currentQueue[0]);
     }
     if (songControl.currentSongIdx < songControl.currentQueue.Count)
     {
         SetPlayer(songControl.currentQueue[songControl.currentSongIdx]);
     }
 }
예제 #2
0
        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
 /// <summary>
 /// 异步获取播放列表
 /// </summary>
 private void getSongList(bool channelChanged=false,bool naturalEnd=false)
 {
     songControl.Next(channelChanged);
     if (!naturalEnd)
     {
         for (int i = 0; i < songControl.currentQueue.Count; i++)
         {
             DefSongList songList = new DefSongList(songControl.currentQueue[i]);
             songList.MouseDoubleClick += delegate
             {
                 songList.removeSong.Visibility = Visibility.Collapsed;
                 SetPlayer(songList.song);
             };
             songListCanvas.Children.Add(songList);
         }
         SetPlayer(songControl.currentQueue[0]);
     }
     if (songControl.currentSongIdx < songControl.currentQueue.Count)
     {
         SetPlayer(songControl.currentQueue[songControl.currentSongIdx]);
     }
 }