By using a CustomBandwidthMeter
and CustomAdaptiveTrackSelection
. Playing an HLS video will start with a fine quality video first then adapt to the network bandwidth.
- Run
yarn
to install the dependencies especiallyexpo-av
. - Run
expo eject
to build the project as a standalone app. - Replace files in
node_modules/expo-av/android/src/main/java/expo/modules/av/player
with the java code infixs
directory using command
cp fixs/* node_modules/expo-av/android/src/main/java/expo/modules/av/player
- Build the app, as usual, using
react-native run-android
andreact-native start
. - Edit the constants in the file
CustomBandwidthMeter.java
changeDEFAULT_INITIAL_BITRATE_ESTIMATE
to select the starting bitrate and in fileCustomAdaptiveTrackSelection.java
changeDEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS
to choose how long to wait before upgrade the video quality. - Rebuild every time after edit the files using command
react-native run-android
- Clone ExoPlayer source code from https://github.com/google/ExoPlayer
- Check the
expo-av
android ExoPlayer dependency version atnode_modules/expo-av/android/android/build.gradle
you will the version like this.
api 'com.google.android.exoplayer:exoplayer:2.9.2'
- Check out the ExoPlayer code at those version by search a commit by version number (e.g.
2.9.2
). - Find the files name
DefaultAdaptiveTrackSelection.java
andDefaultBandwidthMeter.java
from ExoPlayer code then merge it toCustomAdaptiveTrackSelection.java
andCustomBandwidthMeter.java
infixs
respectively. - Update
SimpleExoPlayerData.java
only when major api change.