feat(android): implement asset folder playback (#3733)

* fix(ts): onPlaybackRateChangeData was not correctly typed

* fix: ensure tracks are well displayed in the sample

* feat(android): implement playback from asset folder

* chore(android): fix linter

* chore: move sample mp4 from package assets to exemple assets
This commit is contained in:
Olivier Bouillet
2024-05-06 21:51:17 +02:00
committed by GitHub
parent 51e22abfe3
commit e05da4e9fe
7 changed files with 46 additions and 49 deletions

View File

@@ -7,6 +7,8 @@ import static androidx.media3.common.C.CONTENT_TYPE_RTSP;
import static androidx.media3.common.C.CONTENT_TYPE_SS;
import static androidx.media3.common.C.TIME_END_OF_SOURCE;
import static com.brentvatne.exoplayer.DataSourceUtil.buildAssetDataSourceFactory;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
@@ -841,7 +843,14 @@ public class ReactExoplayerView extends FrameLayout implements
);
break;
case CONTENT_TYPE_OTHER:
if (uri.toString().startsWith("file://") ||
if ("asset".equals(srcUri.getScheme())) {
try {
DataSource.Factory assetDataSourceFactory = buildAssetDataSourceFactory(themedReactContext, srcUri);
mediaSourceFactory = new ProgressiveMediaSource.Factory(assetDataSourceFactory);
} catch (Exception e) {
throw new IllegalStateException("cannot open input file" + srcUri);
}
} else if ("file".equals(srcUri.getScheme()) ||
cacheDataSourceFactory == null) {
mediaSourceFactory = new ProgressiveMediaSource.Factory(
mediaDataSourceFactory