Skip to content

Commit

Permalink
chore(android): improve exoplayer logs (TheWidlarzGroup#3780)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
freeboub authored May 17, 2024
1 parent 8a57b12 commit d716e1a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -508,6 +514,24 @@ private void reLayoutControls() {
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;
Expand Down Expand Up @@ -666,6 +690,7 @@ private void initializePlayerCore(ReactExoplayerView self) {
.setLoadControl(loadControl)
.setMediaSourceFactory(mediaSourceFactory)
.build();
refreshDebugState();
player.addListener(self);
player.setVolume(muted ? 0.f : audioVolume * 1);
exoPlayerView.setPlayer(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ public void setDebug(final ReactExoplayerView videoView,
} else {
DebugLog.setConfig(Log.WARN, enableThreadDebug);
}
videoView.setDebug(enableDebug);
}

private boolean startsWithValidScheme(String uriString) {
Expand Down
1 change: 1 addition & 0 deletions examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ class VideoPlayer extends Component {
onPlaybackRateChange={this.onPlaybackRateChange}
onPlaybackStateChanged={this.onPlaybackStateChanged}
bufferingStrategy={BufferingStrategyType.DEFAULT}
debug={{enable: true, thread: true}}
/>
</TouchableOpacity>
);
Expand Down

0 comments on commit d716e1a

Please sign in to comment.