Exemplo n.º 1
0
        public static IPlaylistParser <IBasePlaylist> GetPlaylistParser(string fileType)
        {
            IPlaylistParser <IBasePlaylist> playlistParser;

            fileType = fileType.ToLower();
            switch (fileType)
            {
            case ".m3u":
                playlistParser = new M3uContent();
                break;

            case ".m3u8":
                playlistParser = new M3u8Content();
                break;

            case ".pls":
                playlistParser = new PlsContent();
                break;

            case ".wpl":
                playlistParser = new WplContent();
                break;

            case ".zpl":
                playlistParser = new ZplContent();
                break;

            default:
                playlistParser = null;
                break;
            }
            return(playlistParser);
        }
        public static string ToText(IBasePlaylist playlist)
        {
            string text = "";

            switch (playlist)
            {
            case M3uPlaylist m3u:
                var m3uWriter = new M3uContent();
                text = m3uWriter.ToText(m3u);
                break;

            case PlsPlaylist pls:
                var plsWriter = new PlsContent();
                text = plsWriter.ToText(pls);
                break;

            case WplPlaylist wpl:
                var wplWriter = new WplContent();
                text = wplWriter.ToText(wpl);
                break;

            case ZplPlaylist zpl:
                var zplWriter = new ZplContent();
                text = zplWriter.ToText(zpl);
                break;

            default:
                break;
            }

            return(text);
        }
Exemplo n.º 3
0
        public static IPlaylistParser <IBasePlaylist> GetPlaylistParser(PlaylistType playlistType)
        {
            IPlaylistParser <IBasePlaylist> playlistParser;

            switch (playlistType)
            {
            case PlaylistType.M3U:
            case PlaylistType.M3U8:
                playlistParser = new M3uContent();
                break;

            case PlaylistType.HLSMaster:
                playlistParser = new HlsMasterContent();
                break;

            case PlaylistType.HlsMedia:
                playlistParser = new HlsMediaContent();
                break;

            case PlaylistType.PLS:
                playlistParser = new PlsContent();
                break;

            case PlaylistType.WPL:
                playlistParser = new WplContent();
                break;

            case PlaylistType.ZPL:
                playlistParser = new ZplContent();
                break;

            default:
                throw new ArgumentException($"Unsupported playlist type: {playlistType}");
            }
            return(playlistParser);
        }