Exemplo n.º 1
0
        public void radioOpen()
        {
            radioItems = new List<PlaylistItem>();
            PlaylistItem item;

            BitmapImage img = new BitmapImage();
            img = new BitmapImage(new Uri("default_radio.png", UriKind.Relative));

            for (int i = 0; i < RADIA.Length; i++)
            {
                item = new PlaylistItem();

                item.cover = img;
                item.radioName = RADIA[i];
                item.frequency = (float)Math.Round((87 + (float)rand.NextDouble() * 21), 1);
                item.artist = item.frequency.ToString();
                item.title = item.radioName;

                radioItems.Add(item);
            }
        }
Exemplo n.º 2
0
        public List<PlaylistItem> generateRadioStation(float frekvencia)
        {
            PlaylistItem item;
            BitmapImage img = new BitmapImage();
            img = new BitmapImage(new Uri("default_radio.png", UriKind.Relative));

            item = new PlaylistItem();
            item.cover = img;
            item.radioName = RADIA[((int)rand.Next()) % RADIA.Length];
            item.frequency = (float)Math.Round(frekvencia,1);
            item.artist = item.frequency.ToString();
            item.title = item.radioName;

            radioItems.Add(item);

            return radioItems;
        }
Exemplo n.º 3
0
        /**
         *  Otvori novy playlist.
         */
        public void Open()
        {
            if (openDialog.ShowDialog() == false) return;

            changed = true;

            items = new List<PlaylistItem>();
            PlaylistItem item;
            TagLib.File id3File;

            MemoryStream memory;
            BitmapImage bmp;

            BitmapImage[] img = new BitmapImage[1];

            img[0] = new BitmapImage(new Uri("default_song.png", UriKind.Relative));

            foreach(FileInfo f in openDialog.Files)
            {
                item = new PlaylistItem();
                id3File = TagLib.File.Create(new TagLib.File.StreamFileAbstraction(f.OpenRead(), f.Name));

                item.file = f;

                //System.Text.Encoding.Convert(System.Text.Encoding.

                if (id3File.Tag.TagTypes.HasFlag(TagLib.TagTypes.Id3v2))
                {
                    item.title = id3File.Tag.Title;
                    item.artist = id3File.Tag.FirstPerformer;
                    item.duration = id3File.Properties.Duration;

                    if (id3File.Tag.Pictures.Length > 0)
                    {
                        memory = new MemoryStream(id3File.Tag.Pictures[0].Data.Data);
                        bmp = new BitmapImage();
                        bmp.SetSource(memory);
                        item.cover = bmp;
                    }
                    else
                    {
                        item.cover = img[0];
                    }
                }
                else
                {
                    item.title = f.Name.Substring(0, f.Name.Length < 20 ? f.Name.Length : 20 );
                    item.artist = "Unknown";
                    item.cover = img[0];
                    item.duration = new TimeSpan(0, 0, 0);
                }

                item.radioName = "Radio " + (items.Count + 1).ToString();
                item.frequency = (float) Math.Round( (87 + (float)rand.NextDouble() * 21), 1);

                items.Add(item);
            }

            this.current = 0;
        }