Before filing a feature request:
When filing a feature request:
Fill out the sections below, leaving the headers but replacing the content. If
you're unable to provide certain information, please explain why in the relevant
section. We may close issues if they do not include sufficient information.
[REQUIRED] Use case description
When I create a raw folder in res folder, I save test.mp4 in res/raw/test.mp4,
I want to play the raw video file with : android.resource schema
But exoplayer cannot play the android.resource schema file
Proposed solution
Author: JeffMony <jeffmony@163.com>
Date: Tue Sep 8 14:56:25 2020 +0800
Fix the problem when video file in res/raw file can be played.
Signed-off-by: JeffMony <jeffmony@163.com>
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultDataSource.java
index afef3e676..582a53b02 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultDataSource.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultDataSource.java
@@ -58,6 +58,7 @@ public final class DefaultDataSource implements DataSource {
private static final String SCHEME_RTMP = "rtmp";
private static final String SCHEME_UDP = "udp";
private static final String SCHEME_RAW = RawResourceDataSource.RAW_RESOURCE_SCHEME;
+ private static final String SCHEME_ANDROID_RESOURCE = RawResourceDataSource.ANDROID_RESOURCE_SCHEME;
private final Context context;
private final List<TransferListener> transferListeners;
@@ -169,7 +170,7 @@ public final class DefaultDataSource implements DataSource {
dataSource = getUdpDataSource();
} else if (DataSchemeDataSource.SCHEME_DATA.equals(scheme)) {
dataSource = getDataSchemeDataSource();
- } else if (SCHEME_RAW.equals(scheme)) {
+ } else if (SCHEME_RAW.equals(scheme) || SCHEME_ANDROID_RESOURCE.equals(scheme)) {
dataSource = getRawResourceDataSource();
} else {
dataSource = baseDataSource;
diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java
index 0595cb84b..4c7c55d85 100644
--- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java
+++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java
@@ -65,6 +65,7 @@ public final class RawResourceDataSource extends BaseDataSource {
/** The scheme part of a raw resource URI. */
public static final String RAW_RESOURCE_SCHEME = "rawresource";
+ public static final String ANDROID_RESOURCE_SCHEME = "android.resource";
private final Resources resources;
@@ -87,7 +88,8 @@ public final class RawResourceDataSource extends BaseDataSource {
try {
Uri uri = dataSpec.uri;
this.uri = uri;
- if (!TextUtils.equals(RAW_RESOURCE_SCHEME, uri.getScheme())) {
+ if (!TextUtils.equals(RAW_RESOURCE_SCHEME, uri.getScheme()) &&
+ !TextUtils.equals(ANDROID_RESOURCE_SCHEME, uri.getScheme())) {
throw new RawResourceDataSourceException("URI must use scheme " + RAW_RESOURCE_SCHEME);
}
Alternatives considered
A clear and concise description of any alternative solutions you considered,
if applicable.
Before filing a feature request:
enhancement
When filing a feature request:
Fill out the sections below, leaving the headers but replacing the content. If
you're unable to provide certain information, please explain why in the relevant
section. We may close issues if they do not include sufficient information.
[REQUIRED] Use case description
When I create a raw folder in res folder, I save test.mp4 in res/raw/test.mp4,
I want to play the raw video file with : android.resource schema
But exoplayer cannot play the android.resource schema file
Proposed solution
Alternatives considered
A clear and concise description of any alternative solutions you considered,
if applicable.