Beispiel #1
0
        public void StreamChanged()
        {
            lyrics = null;//GCC
            lyrics = new Lyrics();
            string artist  = string.Empty;
            string album   = string.Empty;
            string bitrate = string.Empty;
            string title   = string.Empty;

            if (PrestoSDK.PrestoService.Player.CurrentMusic.Artist.Name != null)
            {
                artist = PrestoSDK.PrestoService.Player.CurrentMusic.Artist.Name;
            }
            if (PrestoSDK.PrestoService.Player.CurrentMusic.Album.Name != null)
            {
                album = PrestoSDK.PrestoService.Player.CurrentMusic.Album.Name;
            }
            if (PrestoSDK.PrestoService.Player.CurrentMusic.Title != null)
            {
                title = PrestoSDK.PrestoService.Player.CurrentMusic.Title.ToString();
            }
            bitrate = PrestoSDK.PrestoService.Player.CurrentMusic.Bitrate.ToString();
            try
            {
                CurrentMusic = PrestoSDK.PrestoService.Player.CurrentMusic.Path;
                string   lyricsFileName = Path.GetFileNameWithoutExtension(CurrentMusic) + ".lrc";
                string   parentPath     = Path.GetDirectoryName(CurrentMusic);
                string   path           = Path.Combine(parentPath, lyricsFileName);
                FileInfo file           = new FileInfo(path);

                if (title == string.Empty)
                {
                    title = Path.GetFileNameWithoutExtension(this.CurrentMusic);
                    PrestoSDK.PrestoService.Player.CurrentMusic.Title = title;
                }
                if (file.Exists == true && this.LyricsListIndex == 0)
                {
                    string[] lines = File.ReadAllLines(path, Encoding.Default);
                    this.LyricsParsing(lines);
                }
                else
                {
                    string   lrcData = alsongLRCManager.GetLRCData(title, artist, LyricsListIndex);
                    string[] lines   = lrcData.Split('\n');
                    this.LyricsParsing(lines);
                }
            }
            catch
            {
                if (artist == string.Empty)
                {
                    artist = lyrics.Artist;
                }
                if (album == string.Empty)
                {
                    album = lyrics.Album;
                }
                lyrics.Lines.Add(0, artist + "/" + album + "/" + bitrate + "kbps"
                                 + "\n가사를 불러올 수 없습니다.");
            }
            timeList = lyrics.Lines.Keys.ToList <double>();
        }