Java 类com.google.android.exoplayer2.source.UnrecognizedInputFormatException 实例源码

项目:Exoplayer2Radio    文件:HlsPlaylistParser.java   
@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.");
}
项目:K-Sonic    文件:HlsPlaylistParser.java   
@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.");
}
项目:transistor    文件:HlsPlaylistParser.java   
@Override
public HlsPlaylist parse(Uri uri, InputStream inputStream) throws IOException {
  BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
  Queue<String> extraLines = new ArrayDeque<>();
  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.");
}