Java 类com.google.android.exoplayer.upstream.HttpDataSource.InvalidResponseCodeException 实例源码

项目:Exoplayer_VLC    文件:HlsChunkSource.java   
/**
 * Invoked when an error occurs loading a chunk.
 *
 * @param chunk The chunk whose load failed.
 * @param e The failure.
 * @return True if the error was handled by the source. False otherwise.
 */
public boolean onLoadError(HlsChunk chunk, IOException e) {
  if ((chunk instanceof MediaPlaylistChunk) && (e instanceof InvalidResponseCodeException)) {
    InvalidResponseCodeException responseCodeException = (InvalidResponseCodeException) e;
    int responseCode = responseCodeException.responseCode;
    if (responseCode == 404 || responseCode == 410) {
      MediaPlaylistChunk playlistChunk = (MediaPlaylistChunk) chunk;
      mediaPlaylistBlacklistFlags[playlistChunk.variantIndex] = true;
      if (!allPlaylistsBlacklisted()) {
        // We've handled the 404/410 by blacklisting the playlist.
        Log.w(TAG, "Blacklisted playlist (" + responseCode + "): "
            + playlistChunk.dataSpec.uri);
        return true;
      } else {
        // This was the last non-blacklisted playlist. Don't blacklist it.
        Log.w(TAG, "Final playlist not blacklisted (" + responseCode + "): "
            + playlistChunk.dataSpec.uri);
        mediaPlaylistBlacklistFlags[playlistChunk.variantIndex] = false;
        return false;
      }
    }
  }
  return false;
}
项目:miku    文件:HlsChunkSource.java   
/**
 * Invoked when the {@link HlsSampleSource} encounters an error loading a chunk obtained from
 * this source.
 *
 * @param chunk The chunk whose load encountered the error.
 * @param e The error.
 * @return True if the error was handled by the source. False otherwise.
 */
public boolean onChunkLoadError(Chunk chunk, IOException e) {
  if (chunk.bytesLoaded() == 0
      && (chunk instanceof TsChunk || chunk instanceof MediaPlaylistChunk
          || chunk instanceof EncryptionKeyChunk)
      && (e instanceof InvalidResponseCodeException)) {
    InvalidResponseCodeException responseCodeException = (InvalidResponseCodeException) e;
    int responseCode = responseCodeException.responseCode;
    if (responseCode == 404 || responseCode == 410) {
      int variantIndex;
      if (chunk instanceof TsChunk) {
        TsChunk tsChunk = (TsChunk) chunk;
        variantIndex = getVariantIndex(tsChunk.format);
      } else if (chunk instanceof MediaPlaylistChunk) {
        MediaPlaylistChunk playlistChunk = (MediaPlaylistChunk) chunk;
        variantIndex = playlistChunk.variantIndex;
      } else {
        EncryptionKeyChunk encryptionChunk = (EncryptionKeyChunk) chunk;
        variantIndex = encryptionChunk.variantIndex;
      }
      boolean alreadyBlacklisted = variantBlacklistTimes[variantIndex] != 0;
      variantBlacklistTimes[variantIndex] = SystemClock.elapsedRealtime();
      if (alreadyBlacklisted) {
        // The playlist was already blacklisted.
        Log.w(TAG, "Already blacklisted variant (" + responseCode + "): "
            + chunk.dataSpec.uri);
        return false;
      } else if (!allVariantsBlacklisted()) {
        // We've handled the 404/410 by blacklisting the variant.
        Log.w(TAG, "Blacklisted variant (" + responseCode + "): "
            + chunk.dataSpec.uri);
        return true;
      } else {
        // This was the last non-blacklisted playlist. Don't blacklist it.
        Log.w(TAG, "Final variant not blacklisted (" + responseCode + "): "
            + chunk.dataSpec.uri);
        variantBlacklistTimes[variantIndex] = 0;
        return false;
      }
    }
  }
  return false;
}
项目:ExoPlayer-Demo    文件:HlsChunkSource.java   
/**
 * Invoked when the {@link HlsSampleSource} encounters an error loading a chunk obtained from
 * this source.
 *
 * @param chunk The chunk whose load encountered the error.
 * @param e The error.
 * @return True if the error was handled by the source. False otherwise.
 */
public boolean onChunkLoadError(Chunk chunk, IOException e) {
  if (chunk.bytesLoaded() == 0
      && (chunk instanceof TsChunk || chunk instanceof MediaPlaylistChunk
          || chunk instanceof EncryptionKeyChunk)
      && (e instanceof InvalidResponseCodeException)) {
    InvalidResponseCodeException responseCodeException = (InvalidResponseCodeException) e;
    int responseCode = responseCodeException.responseCode;
    if (responseCode == 404 || responseCode == 410) {
      int variantIndex;
      if (chunk instanceof TsChunk) {
        TsChunk tsChunk = (TsChunk) chunk;
        variantIndex = getVariantIndex(tsChunk.format);
      } else if (chunk instanceof MediaPlaylistChunk) {
        MediaPlaylistChunk playlistChunk = (MediaPlaylistChunk) chunk;
        variantIndex = playlistChunk.variantIndex;
      } else {
        EncryptionKeyChunk encryptionChunk = (EncryptionKeyChunk) chunk;
        variantIndex = encryptionChunk.variantIndex;
      }
      boolean alreadyBlacklisted = variantBlacklistTimes[variantIndex] != 0;
      variantBlacklistTimes[variantIndex] = SystemClock.elapsedRealtime();
      if (alreadyBlacklisted) {
        // The playlist was already blacklisted.
        Log.w(TAG, "Already blacklisted variant (" + responseCode + "): "
            + chunk.dataSpec.uri);
        return false;
      } else if (!allVariantsBlacklisted()) {
        // We've handled the 404/410 by blacklisting the variant.
        Log.w(TAG, "Blacklisted variant (" + responseCode + "): "
            + chunk.dataSpec.uri);
        return true;
      } else {
        // This was the last non-blacklisted playlist. Don't blacklist it.
        Log.w(TAG, "Final variant not blacklisted (" + responseCode + "): "
            + chunk.dataSpec.uri);
        variantBlacklistTimes[variantIndex] = 0;
        return false;
      }
    }
  }
  return false;
}
项目:ExoPlayer    文件:HlsChunkSource.java   
/**
 * Invoked when the {@link HlsSampleSource} encounters an error loading a chunk obtained from
 * this source.
 *
 * @param chunk The chunk whose load encountered the error.
 * @param e The error.
 * @return True if the error was handled by the source. False otherwise.
 */
public boolean onChunkLoadError(Chunk chunk, IOException e) {
  if (chunk.bytesLoaded() == 0
      && (chunk instanceof TsChunk || chunk instanceof MediaPlaylistChunk
          || chunk instanceof EncryptionKeyChunk)
      && (e instanceof InvalidResponseCodeException)) {
    InvalidResponseCodeException responseCodeException = (InvalidResponseCodeException) e;
    int responseCode = responseCodeException.responseCode;
    if (responseCode == 404 || responseCode == 410) {
      int variantIndex;
      if (chunk instanceof TsChunk) {
        TsChunk tsChunk = (TsChunk) chunk;
        variantIndex = getVariantIndex(tsChunk.format);
      } else if (chunk instanceof MediaPlaylistChunk) {
        MediaPlaylistChunk playlistChunk = (MediaPlaylistChunk) chunk;
        variantIndex = playlistChunk.variantIndex;
      } else {
        EncryptionKeyChunk encryptionChunk = (EncryptionKeyChunk) chunk;
        variantIndex = encryptionChunk.variantIndex;
      }
      boolean alreadyBlacklisted = variantBlacklistTimes[variantIndex] != 0;
      variantBlacklistTimes[variantIndex] = SystemClock.elapsedRealtime();
      if (alreadyBlacklisted) {
        // The playlist was already blacklisted.
        Log.w(TAG, "Already blacklisted variant (" + responseCode + "): "
            + chunk.dataSpec.uri);
        return false;
      } else if (!allVariantsBlacklisted()) {
        // We've handled the 404/410 by blacklisting the variant.
        Log.w(TAG, "Blacklisted variant (" + responseCode + "): "
            + chunk.dataSpec.uri);
        return true;
      } else {
        // This was the last non-blacklisted playlist. Don't blacklist it.
        Log.w(TAG, "Final variant not blacklisted (" + responseCode + "): "
            + chunk.dataSpec.uri);
        variantBlacklistTimes[variantIndex] = 0;
        return false;
      }
    }
  }
  return false;
}