fix(android): implement live configuration management (#3792)
* perf: ensure we do not provide callback to native if no callback provided from app * chore: rework bufferConfig to make it more generic and reduce ReactExoplayerView code size * chore: improve issue template * fix(android): avoid video view flickering at playback startup * feat(android): implement live buffer configuration * chore: fix linter
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.brentvatne.exoplayer
|
||||
|
||||
import androidx.media3.common.MediaItem.LiveConfiguration
|
||||
import com.brentvatne.common.api.BufferConfig
|
||||
import com.brentvatne.common.api.BufferConfig.Live
|
||||
|
||||
/**
|
||||
* Helper functions to create exoplayer configuration
|
||||
*/
|
||||
object ConfigurationUtils {
|
||||
|
||||
/**
|
||||
* Create a media3.LiveConfiguration.Builder from parsed BufferConfig
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getLiveConfiguration(bufferConfig: BufferConfig): LiveConfiguration.Builder {
|
||||
val liveConfiguration = LiveConfiguration.Builder()
|
||||
val live: Live = bufferConfig.live
|
||||
if (bufferConfig.live.maxOffsetMs >= 0) {
|
||||
liveConfiguration.setMaxOffsetMs(live.maxOffsetMs)
|
||||
}
|
||||
if (bufferConfig.live.maxPlaybackSpeed >= 0) {
|
||||
liveConfiguration.setMaxPlaybackSpeed(live.maxPlaybackSpeed)
|
||||
}
|
||||
if (bufferConfig.live.targetOffsetMs >= 0) {
|
||||
liveConfiguration.setTargetOffsetMs(live.targetOffsetMs)
|
||||
}
|
||||
if (bufferConfig.live.minOffsetMs >= 0) {
|
||||
liveConfiguration.setMinOffsetMs(live.minOffsetMs)
|
||||
}
|
||||
if (bufferConfig.live.minPlaybackSpeed >= 0) {
|
||||
liveConfiguration.setMinPlaybackSpeed(live.minPlaybackSpeed)
|
||||
}
|
||||
return liveConfiguration
|
||||
}
|
||||
}
|
||||
@@ -965,6 +965,9 @@ public class ReactExoplayerView extends FrameLayout implements
|
||||
);
|
||||
}
|
||||
|
||||
MediaItem.LiveConfiguration.Builder liveConfiguration = ConfigurationUtils.getLiveConfiguration(bufferConfig);
|
||||
mediaItemBuilder.setLiveConfiguration(liveConfiguration.build());
|
||||
|
||||
MediaSource.Factory mediaSourceFactory;
|
||||
DrmSessionManagerProvider drmProvider;
|
||||
List<StreamKey> streamKeys = new ArrayList();
|
||||
|
||||
Reference in New Issue
Block a user