public void testParseMedia() { String absolute = "http://www.my.song/file1.mp3"; String relative = "user1/file2.mp3"; String validData = "#EXTM3U\n" + "#EXT-X-VERSION:2\n" + "#EXT-X-TARGETDURATION:60\n" + "#EXT-X-MEDIA-SEQUENCE:10\n" + "#some comment\n" + "#EXTINF:120.0,title 1\n" + absolute + "\n" + "#EXTINF:100.0,title 2\n" + "#EXT-X-PROGRAM-DATE-TIME:2010-02-19T14:54:23.031+08:00\n" + "\n" + relative + "\n" + "\n"; List <TrackData> expectedTracks = new List <TrackData>() { new TrackData.Builder().withUri(absolute).withTrackInfo(new TrackInfo(120, "title 1")).build(), new TrackData.Builder().withUri(relative).withTrackInfo(new TrackInfo(100, "title 2")).withProgramDateTime("2010-02-19T14:54:23.031+08:00").build() }; Stream inputStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(validData)); Playlist playlist = new ExtendedM3uParser(inputStream, Encoding.UTF_8, ParsingMode.STRICT).parse(); Assert.True(playlist.isExtended()); Assert.Equal(2, playlist.getCompatibilityVersion()); Assert.True(playlist.hasMediaPlaylist()); Assert.Equal(60, playlist.getMediaPlaylist().getTargetDuration()); Assert.Equal(10, playlist.getMediaPlaylist().getMediaSequenceNumber()); Assert.Equal(expectedTracks, playlist.getMediaPlaylist().getTracks()); }
public void testLenientParsing() { String validData = "#EXTM3U\n" + "#EXT-X-VERSION:2\n" + "#EXT-X-TARGETDURATION:60\n" + "#EXT-X-MEDIA-SEQUENCE:10\n" + "#EXT-FAXS-CM:MIIa4QYJKoZIhvcNAQcCoIIa0jCCGs4C...\n" + "#some comment\n" + "#EXTINF:120.0,title 1\n" + "http://www.my.song/file1.mp3\n" + "\n"; Stream inputStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(validData)); Playlist playlist = new ExtendedM3uParser(inputStream, Encoding.UTF_8, ParsingMode.LENIENT).parse(); Assert.True(playlist.isExtended()); Assert.True(playlist.getMediaPlaylist().hasUnknownTags()); Assert.True(playlist.getMediaPlaylist().getUnknownTags()[0].Length > 0); }