diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java index 7f84d271707..26a3d66c9e5 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java @@ -411,10 +411,10 @@ public long open(DataSpec dataSpec) throws HttpDataSourceException { throw new InvalidContentTypeException(contentType, dataSpec); } - // If we requested a range starting from a non-zero position and received a 200 rather than a - // 206, then the server does not support partial requests. We'll need to manually skip to the - // requested position. - long bytesToSkip = responseCode == 200 && dataSpec.position != 0 ? dataSpec.position : 0; + // If we requested a range starting from a non-zero position and did not receive a 206, then + // the server does not support partial requests. We'll need to manually skip to the requested + // position. + long bytesToSkip = responseCode != 206 && dataSpec.position != 0 ? dataSpec.position : 0; // Determine the length of the data to be read, after skipping. boolean isCompressed = isCompressed(connection); diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java index 07b96e9a101..47f763c32e8 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/HttpEngineDataSource.java @@ -540,10 +540,10 @@ public long open(DataSpec dataSpec) throws HttpDataSourceException { } } - // If we requested a range starting from a non-zero position and received a 200 rather than a - // 206, then the server does not support partial requests. We'll need to manually skip to the - // requested position. - long bytesToSkip = responseCode == 200 && dataSpec.position != 0 ? dataSpec.position : 0; + // If we requested a range starting from a non-zero position and did not receive a 206, then + // the server does not support partial requests. We'll need to manually skip to the requested + // position. + long bytesToSkip = responseCode != 206 && dataSpec.position != 0 ? dataSpec.position : 0; // Calculate the content length. if (!isCompressed(responseInfo)) { diff --git a/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java b/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java index 53f3bd0aacf..8e42bf053b4 100644 --- a/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java +++ b/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java @@ -670,10 +670,10 @@ public long open(DataSpec dataSpec) throws HttpDataSourceException { } } - // If we requested a range starting from a non-zero position and received a 200 rather than a - // 206, then the server does not support partial requests. We'll need to manually skip to the - // requested position. - long bytesToSkip = responseCode == 200 && dataSpec.position != 0 ? dataSpec.position : 0; + // If we requested a range starting from a non-zero position and did not receive a 206, then + // the server does not support partial requests. We'll need to manually skip to the requested + // position. + long bytesToSkip = responseCode != 206 && dataSpec.position != 0 ? dataSpec.position : 0; // Calculate the content length. if (!isCompressed(responseInfo)) { diff --git a/libraries/datasource_ktor/src/main/java/androidx/media3/datasource/ktor/KtorDataSource.kt b/libraries/datasource_ktor/src/main/java/androidx/media3/datasource/ktor/KtorDataSource.kt index a56c3a34f01..81523a395bb 100644 --- a/libraries/datasource_ktor/src/main/java/androidx/media3/datasource/ktor/KtorDataSource.kt +++ b/libraries/datasource_ktor/src/main/java/androidx/media3/datasource/ktor/KtorDataSource.kt @@ -227,7 +227,7 @@ private constructor( throw HttpDataSource.InvalidContentTypeException(contentType, dataSpec) } - val bytesToSkip = if (responseCode == 200 && dataSpec.position != 0L) dataSpec.position else 0L + val bytesToSkip = if (responseCode != 206 && dataSpec.position != 0L) dataSpec.position else 0L if (dataSpec.length != C.LENGTH_UNSET.toLong()) { bytesToRead = dataSpec.length diff --git a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java index 1c24144c242..6b35144bef8 100644 --- a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java +++ b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java @@ -317,10 +317,10 @@ public long open(DataSpec dataSpec) throws HttpDataSourceException { throw new InvalidContentTypeException(contentType, dataSpec); } - // If we requested a range starting from a non-zero position and received a 200 rather than a - // 206, then the server does not support partial requests. We'll need to manually skip to the - // requested position. - long bytesToSkip = responseCode == 200 && dataSpec.position != 0 ? dataSpec.position : 0; + // If we requested a range starting from a non-zero position and did not receive a 206, then + // the server does not support partial requests. We'll need to manually skip to the requested + // position. + long bytesToSkip = responseCode != 206 && dataSpec.position != 0 ? dataSpec.position : 0; // Determine the length of the data to be read, after skipping. if (dataSpec.length != C.LENGTH_UNSET) {