mirror of
https://github.com/samsonjs/media.git
synced 2026-04-21 13:55:47 +00:00
ContentDataSource: Restore ability to open file URIs
PiperOrigin-RevId: 388410558
This commit is contained in:
parent
f329adbc23
commit
bffa3e0afb
1 changed files with 13 additions and 7 deletions
|
|
@ -79,16 +79,22 @@ public final class ContentDataSource extends BaseDataSource {
|
|||
|
||||
transferInitializing(dataSpec);
|
||||
|
||||
Bundle providerOptions = new Bundle();
|
||||
if (Util.SDK_INT >= 31) {
|
||||
Api31.disableTranscoding(providerOptions);
|
||||
AssetFileDescriptor assetFileDescriptor;
|
||||
if ("content".equals(dataSpec.uri.getScheme())) {
|
||||
Bundle providerOptions = new Bundle();
|
||||
if (Util.SDK_INT >= 31) {
|
||||
Api31.disableTranscoding(providerOptions);
|
||||
}
|
||||
assetFileDescriptor =
|
||||
resolver.openTypedAssetFileDescriptor(uri, /* mimeType= */ "*/*", providerOptions);
|
||||
} else {
|
||||
// This path supports file URIs, although support may be removed in the future. See
|
||||
// [Internal ref: b/195384732].
|
||||
assetFileDescriptor = resolver.openAssetFileDescriptor(uri, "r");
|
||||
}
|
||||
|
||||
AssetFileDescriptor assetFileDescriptor =
|
||||
resolver.openTypedAssetFileDescriptor(uri, /* mimeType= */ "*/*", providerOptions);
|
||||
this.assetFileDescriptor = assetFileDescriptor;
|
||||
if (assetFileDescriptor == null) {
|
||||
// openTypedAssetFileDescriptor returns null if the provider recently crashed.
|
||||
// assetFileDescriptor may be null if the provider recently crashed.
|
||||
throw new ContentDataSourceException(
|
||||
new IOException("Could not open file descriptor for: " + uri),
|
||||
PlaybackException.ERROR_CODE_IO_UNSPECIFIED);
|
||||
|
|
|
|||
Loading…
Reference in a new issue