Exemple #1
0
        private bool readTags(string[] Tags)
        {
            List <string> tags = new List <string>(Tags);

            if (station.Name.Length == 0)
            {
                string nameMarker = "icy-name:";
                string name       = tags.FirstOrDefault(s => s.StartsWith(nameMarker, StringComparison.OrdinalIgnoreCase));
                if (name != null)
                {
                    station.Name = name.Substring(nameMarker.Length).Trim();
                    Radio.StationNameChanged();
                }
            }
            if (station.BitRate == 0)
            {
                string bitRateMarker = "icy-br:";
                string bitRate       = tags.FirstOrDefault(s => s.StartsWith(bitRateMarker, StringComparison.OrdinalIgnoreCase));
                if (bitRate != null)
                {
                    int br;
                    if (Int32.TryParse(bitRate.Substring(bitRateMarker.Length).Trim(), out br))
                    {
                        station.BitRate = br;
                        Radio.InvalidateInstance();
                    }
                }
            }
            if (station.Genre.Length == 0)
            {
                string genreMarker = "icy-genre:";
                string genre       = tags.FirstOrDefault(s => s.StartsWith(genreMarker, StringComparison.OrdinalIgnoreCase));
                if (genre != null)
                {
                    station.Genre = genre.Substring(genreMarker.Length).Trim();
                    Radio.StationGenreChanged();
                }
            }
            return(false);
        }
Exemple #2
0
        private void getTagsFromURL()
        {
            if (BassTags.BASS_TAG_GetFromURL(streamRef, tagInfo))
            {
                int trackNum = 0;
                Int32.TryParse(tagInfo.track, out trackNum);
                int year = 0;
                Int32.TryParse(tagInfo.year, out year);
                Track t = new Track(0,
                                    tagInfo.title + tagInfo.artist, // need something since equals uses filepath
                                    Track.FileType.None,
                                    tagInfo.title,
                                    String.Empty,
                                    tagInfo.artist,
                                    tagInfo.albumartist,
                                    tagInfo.composer,
                                    String.Empty,
                                    String.Empty,
                                    0,
                                    trackNum,
                                    0,
                                    year,
                                    0,
                                    0,
                                    tagInfo.bitrate,
                                    0,
                                    false,
                                    DateTime.Now,
                                    DateTime.Now,
                                    DateTime.Now,
                                    tagInfo.encodedby,
                                    tagInfo.channelinfo.chans,
                                    tagInfo.channelinfo.sample,
                                    ChangeType.None,
                                    null,
                                    float.MinValue,
                                    float.MinValue);

                if (station.Name.Length == 0 && tagInfo.album.Trim().Length > 0)
                {
                    station.Name = tagInfo.album.Trim();
                    Radio.StationNameChanged();
                }
                if (station.Name.Length == 0 && tagInfo.title.Trim().Length > 0)
                {
                    station.Name = tagInfo.title.Trim();
                    Radio.StationNameChanged();
                }
                if (station.Genre.Length == 0 && tagInfo.genre.Trim().Length > 0)
                {
                    station.Genre = tagInfo.genre.Trim();
                    Radio.StationGenreChanged();
                }

                if (tagInfo.bitrate > 0)
                {
                    station.BitRate = tagInfo.bitrate;
                }

                Radio.InvalidateInstance();
                controller.RadioTrack = t;
                controller.Invalidate();
            }
        }