Bandwidth reporting
To show the current bandwidth to user and for debugging purposes current bandwidth is required to be reported. This pull request adds the bandwidth estimate in the progress event. Also the bandwidth details are added in the audio track in load event. There is another pull request which reports the video track information
This commit is contained in:
parent
16688cef0f
commit
4ea926e137
@ -149,9 +149,10 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
&& player.getPlaybackState() == ExoPlayer.STATE_READY
|
||||
&& player.getPlayWhenReady()
|
||||
) {
|
||||
long bitRateEstimate = BANDWIDTH_METER.getBitrateEstimate();
|
||||
long pos = player.getCurrentPosition();
|
||||
long bufferedDuration = player.getBufferedPercentage() * player.getDuration() / 100;
|
||||
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration());
|
||||
eventEmitter.progressChanged(pos, bufferedDuration, player.getDuration(), bitRateEstimate);
|
||||
msg = obtainMessage(SHOW_PROGRESS);
|
||||
sendMessageDelayed(msg, Math.round(mProgressUpdateInterval));
|
||||
}
|
||||
@ -542,6 +543,8 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
audioTrack.putString("title", format.id != null ? format.id : "");
|
||||
audioTrack.putString("type", format.sampleMimeType);
|
||||
audioTrack.putString("language", format.language != null ? format.language : "");
|
||||
audioTrack.putString("bitrate", format.bitrate == Format.NO_VALUE ? ""
|
||||
: String.format(Locale.US, "%.2fMbps", format.bitrate / 1000000f));
|
||||
audioTracks.pushMap(audioTrack);
|
||||
}
|
||||
return audioTracks;
|
||||
|
@ -103,6 +103,7 @@ class VideoEventEmitter {
|
||||
private static final String EVENT_PROP_DURATION = "duration";
|
||||
private static final String EVENT_PROP_PLAYABLE_DURATION = "playableDuration";
|
||||
private static final String EVENT_PROP_SEEKABLE_DURATION = "seekableDuration";
|
||||
private static final String EVENT_PROP_BITRATE_ESTIMATE = "bitrateEstimate";
|
||||
private static final String EVENT_PROP_CURRENT_TIME = "currentTime";
|
||||
private static final String EVENT_PROP_SEEK_TIME = "seekTime";
|
||||
private static final String EVENT_PROP_NATURAL_SIZE = "naturalSize";
|
||||
@ -163,11 +164,12 @@ class VideoEventEmitter {
|
||||
receiveEvent(EVENT_LOAD, event);
|
||||
}
|
||||
|
||||
void progressChanged(double currentPosition, double bufferedDuration, double seekableDuration) {
|
||||
void progressChanged(double currentPosition, double bufferedDuration, double seekableDuration, double bitRateEstimate) {
|
||||
WritableMap event = Arguments.createMap();
|
||||
event.putDouble(EVENT_PROP_CURRENT_TIME, currentPosition / 1000D);
|
||||
event.putDouble(EVENT_PROP_PLAYABLE_DURATION, bufferedDuration / 1000D);
|
||||
event.putDouble(EVENT_PROP_SEEKABLE_DURATION, seekableDuration / 1000D);
|
||||
event.putDouble(EVENT_PROP_BITRATE_ESTIMATE, bitRateEstimate / 1000D);
|
||||
receiveEvent(EVENT_PROGRESS, event);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user