diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index bcac252f..eb303e14 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -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; diff --git a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java index fca24062..a7fa2436 100644 --- a/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java +++ b/android-exoplayer/src/main/java/com/brentvatne/exoplayer/VideoEventEmitter.java @@ -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); }