From f558d05923bb9f487daf5c82b4201ef63bb25498 Mon Sep 17 00:00:00 2001 From: Gabriel Rivero Date: Fri, 26 Aug 2022 10:32:22 -0400 Subject: [PATCH 1/4] upgrade exoplayer --- android/build.gradle | 4 ++-- .../brentvatne/exoplayer/ExoPlayerView.java | 6 +++--- .../exoplayer/ReactExoplayerView.java | 21 +++++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index a93e7599..16c54864 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -33,7 +33,7 @@ repositories { dependencies { implementation "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}" - implementation('com.google.android.exoplayer:exoplayer:2.17.1') { + implementation('com.google.android.exoplayer:exoplayer:2.18.1') { exclude group: 'com.android.support' } @@ -42,7 +42,7 @@ dependencies { implementation "androidx.core:core:1.1.0" implementation "androidx.media:media:1.1.0" - implementation('com.google.android.exoplayer:extension-okhttp:2.17.1') { + implementation('com.google.android.exoplayer:extension-okhttp:2.18.1') { exclude group: 'com.squareup.okhttp3', module: 'okhttp' } implementation 'com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}' diff --git a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java index a6cd1c4f..ce52f7df 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ExoPlayerView.java @@ -18,7 +18,7 @@ import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.Timeline; -import com.google.android.exoplayer2.TracksInfo; +import com.google.android.exoplayer2.Tracks; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.ui.SubtitleView; @@ -230,7 +230,7 @@ public final class ExoPlayerView extends FrameLayout { @Override public void onCues(List cues) { - subtitleLayout.onCues(cues); + subtitleLayout.setCues(cues); } // ExoPlayer.VideoListener implementation @@ -284,7 +284,7 @@ public final class ExoPlayerView extends FrameLayout { } @Override - public void onTracksInfoChanged(TracksInfo tracksInfo) { + public void onTracksChanged(Tracks tracks) { updateForCurrentTrackSelections(); } diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 9a790fdc..448d1946 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -42,8 +42,9 @@ import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.Timeline; -import com.google.android.exoplayer2.TracksInfo; +import com.google.android.exoplayer2.Tracks; import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; +import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider; import com.google.android.exoplayer2.drm.DrmSessionEventListener; import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManagerProvider; @@ -72,8 +73,8 @@ import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.MappingTrackSelector; import com.google.android.exoplayer2.trackselection.ExoTrackSelection; -import com.google.android.exoplayer2.trackselection.TrackSelectionOverrides; -import com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride; +import com.google.android.exoplayer2.trackselection.TrackSelectionParameters; +import com.google.android.exoplayer2.trackselection.TrackSelectionOverride; import com.google.android.exoplayer2.ui.PlayerControlView; import com.google.android.exoplayer2.upstream.BandwidthMeter; import com.google.android.exoplayer2.upstream.DataSource; @@ -548,7 +549,7 @@ class ReactExoplayerView extends FrameLayout implements private void initializePlayerCore(ReactExoplayerView self) { ExoTrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(); - self.trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory); + self.trackSelector = new DefaultTrackSelector(getContext(), videoTrackSelectionFactory); self.trackSelector.setParameters(trackSelector.buildUponParameters() .setMaxVideoBitrate(maxBitRate == 0 ? Integer.MAX_VALUE : maxBitRate)); @@ -698,6 +699,8 @@ class ReactExoplayerView extends FrameLayout implements return drmSessionManager; } }; + } else { + drmProvider = new DefaultDrmSessionManagerProvider(); } switch (type) { case C.TYPE_SS: @@ -1253,7 +1256,7 @@ class ReactExoplayerView extends FrameLayout implements } @Override - public void onTracksInfoChanged(TracksInfo tracksInfo) { + public void onTracksChanged(Tracks tracks) { // Do nothing. } @@ -1565,10 +1568,10 @@ class ReactExoplayerView extends FrameLayout implements TrackSelectionOverride selectionOverride = new TrackSelectionOverride(groups.get(groupIndex), tracks); DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters() - .buildUpon() - .setRendererDisabled(rendererIndex, false) - .setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().addOverride(selectionOverride).build()) - .build(); + .buildUpon() + .setRendererDisabled(rendererIndex, false) + .addOverride(selectionOverride) + .build(); trackSelector.setParameters(selectionParameters); } From d490c300efe13aa3989d7e60d6cbc070c81e90b7 Mon Sep 17 00:00:00 2001 From: Karl Date: Sat, 3 Sep 2022 08:29:46 +0100 Subject: [PATCH 2/4] Update API.md --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index 0ce67252..48401b78 100644 --- a/API.md +++ b/API.md @@ -214,7 +214,7 @@ Follow the manual linking instuctions for React Native Windows 0.62 above, but s ## Examples -Run `yarn xbasic install` before running any of the examples. +Run `yarn xbasic install` in the root directory before running any of the examples. ### iOS Example ``` From 98380f0fb9fe54532359abbecfa97aebcb4606f3 Mon Sep 17 00:00:00 2001 From: Karl Date: Tue, 6 Sep 2022 15:34:26 +0100 Subject: [PATCH 3/4] Docs: Add note to `disableFocus` explaining that it allows multiple videos to play. --- API.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index 48401b78..d9153f77 100644 --- a/API.md +++ b/API.md @@ -433,7 +433,9 @@ Platforms: Android, iOS Determines whether video audio should override background music/audio in Android devices. * **false (default)** - Override background audio/music * **true** - Let background audio/music from other apps play - + +Note: Allows multiple videos to play if set to `true`. If `false`, when one video is playing and another is started, the first video will be paused. + Platforms: Android #### disableDisconnectError From a1bea1ab97b0d923a8ae5ce25e6eb7728941a9d1 Mon Sep 17 00:00:00 2001 From: Gabriel Rivero Date: Tue, 6 Sep 2022 12:09:00 -0400 Subject: [PATCH 4/4] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66ee8d89..fb33794d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,6 @@ ## Changelog +### Version 6.0.0-alpha3 +- Upgrade ExoPlayer to 2.18.1 [#2846](https://github.com/react-native-video/react-native-video/pull/2846) ### Version 6.0.0-alpha2