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:
parent
8a57b127d0
commit
d716e1ab2a
@ -97,6 +97,7 @@ import androidx.media3.exoplayer.trackselection.TrackSelectionArray;
|
|||||||
import androidx.media3.exoplayer.upstream.BandwidthMeter;
|
import androidx.media3.exoplayer.upstream.BandwidthMeter;
|
||||||
import androidx.media3.exoplayer.upstream.DefaultAllocator;
|
import androidx.media3.exoplayer.upstream.DefaultAllocator;
|
||||||
import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter;
|
import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter;
|
||||||
|
import androidx.media3.exoplayer.util.EventLogger;
|
||||||
import androidx.media3.extractor.metadata.emsg.EventMessage;
|
import androidx.media3.extractor.metadata.emsg.EventMessage;
|
||||||
import androidx.media3.extractor.metadata.id3.Id3Frame;
|
import androidx.media3.extractor.metadata.id3.Id3Frame;
|
||||||
import androidx.media3.extractor.metadata.id3.TextInformationFrame;
|
import androidx.media3.extractor.metadata.id3.TextInformationFrame;
|
||||||
@ -185,6 +186,11 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
private ServiceConnection playbackServiceConnection;
|
private ServiceConnection playbackServiceConnection;
|
||||||
private PlaybackServiceBinder playbackServiceBinder;
|
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 int resumeWindow;
|
||||||
private long resumePosition;
|
private long resumePosition;
|
||||||
private boolean loadVideoStarted;
|
private boolean loadVideoStarted;
|
||||||
@ -508,6 +514,24 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
reLayout(playerControlView);
|
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 class RNVLoadControl extends DefaultLoadControl {
|
||||||
private final int availableHeapInBytes;
|
private final int availableHeapInBytes;
|
||||||
private final Runtime runtime;
|
private final Runtime runtime;
|
||||||
@ -666,6 +690,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
.setLoadControl(loadControl)
|
.setLoadControl(loadControl)
|
||||||
.setMediaSourceFactory(mediaSourceFactory)
|
.setMediaSourceFactory(mediaSourceFactory)
|
||||||
.build();
|
.build();
|
||||||
|
refreshDebugState();
|
||||||
player.addListener(self);
|
player.addListener(self);
|
||||||
player.setVolume(muted ? 0.f : audioVolume * 1);
|
player.setVolume(muted ? 0.f : audioVolume * 1);
|
||||||
exoPlayerView.setPlayer(player);
|
exoPlayerView.setPlayer(player);
|
||||||
|
@ -448,6 +448,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
} else {
|
} else {
|
||||||
DebugLog.setConfig(Log.WARN, enableThreadDebug);
|
DebugLog.setConfig(Log.WARN, enableThreadDebug);
|
||||||
}
|
}
|
||||||
|
videoView.setDebug(enableDebug);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean startsWithValidScheme(String uriString) {
|
private boolean startsWithValidScheme(String uriString) {
|
||||||
|
@ -936,6 +936,7 @@ class VideoPlayer extends Component {
|
|||||||
onPlaybackRateChange={this.onPlaybackRateChange}
|
onPlaybackRateChange={this.onPlaybackRateChange}
|
||||||
onPlaybackStateChanged={this.onPlaybackStateChanged}
|
onPlaybackStateChanged={this.onPlaybackStateChanged}
|
||||||
bufferingStrategy={BufferingStrategyType.DEFAULT}
|
bufferingStrategy={BufferingStrategyType.DEFAULT}
|
||||||
|
debug={{enable: true, thread: true}}
|
||||||
/>
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user