chore(android): improve exoplayer logs (#3780)

* 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

* fix: improve debuging display and enable it in the sample
This commit is contained in:
Olivier Bouillet 2024-05-17 15:10:37 +02:00 committed by GitHub
parent 8a57b127d0
commit d716e1ab2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View File

@ -97,6 +97,7 @@ import androidx.media3.exoplayer.trackselection.TrackSelectionArray;
import androidx.media3.exoplayer.upstream.BandwidthMeter;
import androidx.media3.exoplayer.upstream.DefaultAllocator;
import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter;
import androidx.media3.exoplayer.util.EventLogger;
import androidx.media3.extractor.metadata.emsg.EventMessage;
import androidx.media3.extractor.metadata.id3.Id3Frame;
import androidx.media3.extractor.metadata.id3.TextInformationFrame;
@ -185,6 +186,11 @@ public class ReactExoplayerView extends FrameLayout implements
private ServiceConnection playbackServiceConnection;
private PlaybackServiceBinder playbackServiceBinder;
// logger to be enable by props
private EventLogger debugEventLogger = null;
private boolean enableDebug = false;
private static final String TAG_EVENT_LOGGER = "RNVExoplayer";
private int resumeWindow;
private long resumePosition;
private boolean loadVideoStarted;
@ -508,6 +514,24 @@ public class ReactExoplayerView extends FrameLayout implements
reLayout(playerControlView);
}
public void setDebug(boolean enableDebug) {
this.enableDebug = enableDebug;
refreshDebugState();
}
private void refreshDebugState() {
if (player == null) {
return;
}
if (enableDebug) {
debugEventLogger = new EventLogger(TAG_EVENT_LOGGER);
player.addAnalyticsListener(debugEventLogger);
} else if (debugEventLogger != null) {
player.removeAnalyticsListener(debugEventLogger);
debugEventLogger = null;
}
}
private class RNVLoadControl extends DefaultLoadControl {
private final int availableHeapInBytes;
private final Runtime runtime;
@ -666,6 +690,7 @@ public class ReactExoplayerView extends FrameLayout implements
.setLoadControl(loadControl)
.setMediaSourceFactory(mediaSourceFactory)
.build();
refreshDebugState();
player.addListener(self);
player.setVolume(muted ? 0.f : audioVolume * 1);
exoPlayerView.setPlayer(player);

View File

@ -448,6 +448,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
} else {
DebugLog.setConfig(Log.WARN, enableThreadDebug);
}
videoView.setDebug(enableDebug);
}
private boolean startsWithValidScheme(String uriString) {

View File

@ -936,6 +936,7 @@ class VideoPlayer extends Component {
onPlaybackRateChange={this.onPlaybackRateChange}
onPlaybackStateChanged={this.onPlaybackStateChanged}
bufferingStrategy={BufferingStrategyType.DEFAULT}
debug={{enable: true, thread: true}}
/>
</TouchableOpacity>
);