public void Create_CreatePlaylistAndCompareWithFile_Equal()
        {
            PlsContent  content  = new PlsContent();
            PlsPlaylist playlist = new PlsPlaylist();

            playlist.Version = 2;
            playlist.PlaylistEntries.Add(new PlsPlaylistEntry()
            {
                Length = TimeSpan.Zero,
                Nr     = 1,
                Path   = "http://stream3.polskieradio.pl:8902/",
                Title  = null,
            });
            playlist.PlaylistEntries.Add(new PlsPlaylistEntry()
            {
                Length = TimeSpan.FromSeconds(-1),
                Nr     = 1,
                Path   = "http://stream.polskastacja.pl/ps43_mp3?player_group=PS_EXT_MP3",
                Title  = "Server1-> >>> P O L S K A S T A C J A <<<- Ballady Rockowe",
            });
            playlist.PlaylistEntries.Add(new PlsPlaylistEntry()
            {
                Length = TimeSpan.FromSeconds(5720),
                Nr     = 1,
                Path   = "/home/uzytkownik/muzyka-1.mp3",
                Title  = "Myslovitz - Sprzedawcy Marzeń",
            });

            string created  = content.ToText(playlist);
            string fromFile = Helpers.Read("Playlist.pls");

            Assert.AreEqual(created, fromFile);
        }
Exemple #2
0
        private void CreatePlaylist()
        {
            string folder            = textBoxFolder.Text;
            string textPlaylist      = string.Empty;
            string playlistExtension = string.Empty;

            switch (comboBoxPlaylist.SelectedItem)
            {
            case Constants.WinMediaPlayerPLS:

                PlsPlaylist plsPlaylist = new PlsPlaylist();
                playlistExtension = "pls";

                foreach (var episode in listBoxEpisodes.Items)
                {
                    plsPlaylist.PlaylistEntries.Add(new PlsPlaylistEntry()
                    {
                        Path  = Path.Combine(folder, episode.ToString()),
                        Title = Path.GetFileNameWithoutExtension(episode.ToString())
                    });
                }

                PlsContent plsContent = new PlsContent();
                textPlaylist = plsContent.ToText(plsPlaylist);

                break;

            case Constants.WinampM3U:

                M3uPlaylist m3uPlaylist = new M3uPlaylist();
                playlistExtension = "m3u";

                foreach (var episode in listBoxEpisodes.Items)
                {
                    m3uPlaylist.PlaylistEntries.Add(new M3uPlaylistEntry()
                    {
                        Path  = Path.Combine(folder, episode.ToString()),
                        Title = Path.GetFileNameWithoutExtension(episode.ToString())
                    });
                }

                M3uContent m3uContent = new M3uContent();
                textPlaylist = m3uContent.ToText(m3uPlaylist);

                break;

            default:
                break;
            }

            string playlistName     = $"Playlist - {Utils.GetTimestamp(DateTime.Now)}";
            string playlistFullName = Path.Combine(folder, $"{playlistName}.{playlistExtension}");

            using (FileStream fs = File.Create(playlistFullName))
            {
                byte[] info = new UTF8Encoding(true).GetBytes(textPlaylist);
                fs.Write(info, 0, info.Length);
            }
        }