use of com.google.android.exoplayer2.source.UnrecognizedInputFormatException in project ExoPlayer by google.
the class HlsPlaylistParser method parse.
@Override
public HlsPlaylist parse(Uri uri, InputStream inputStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
Queue<String> extraLines = new LinkedList<>();
String line;
try {
if (!checkPlaylistHeader(reader)) {
throw new UnrecognizedInputFormatException("Input does not start with the #EXTM3U header.", uri);
}
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.isEmpty()) {
// Do nothing.
} else if (line.startsWith(TAG_STREAM_INF)) {
extraLines.add(line);
return parseMasterPlaylist(new LineIterator(extraLines, reader), uri.toString());
} else if (line.startsWith(TAG_TARGET_DURATION) || line.startsWith(TAG_MEDIA_SEQUENCE) || line.startsWith(TAG_MEDIA_DURATION) || line.startsWith(TAG_KEY) || line.startsWith(TAG_BYTERANGE) || line.equals(TAG_DISCONTINUITY) || line.equals(TAG_DISCONTINUITY_SEQUENCE) || line.equals(TAG_ENDLIST)) {
extraLines.add(line);
return parseMediaPlaylist(new LineIterator(extraLines, reader), uri.toString());
} else {
extraLines.add(line);
}
}
} finally {
Util.closeQuietly(reader);
}
throw new ParserException("Failed to parse the playlist, could not identify any tags.");
}
Aggregations