Merge branch 'master' of https://github.com/react-native-video/react-native-video into feat/add_new_events_on_tracks_changed

# Conflicts:
#	CHANGELOG.md
#	android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java
#	examples/basic/src/VideoPlayer.android.tsx
This commit is contained in:
olivier bouillet
2022-10-29 15:20:36 +02:00
18 changed files with 283 additions and 164 deletions

View File

@@ -27,8 +27,7 @@ android {
}
repositories {
// Remove this repository line after google releases to google() or mavenCentral()
maven { url "https://dl.google.com/android/maven2" }
google()
}
dependencies {
@@ -41,11 +40,10 @@ dependencies {
implementation "androidx.annotation:annotation:1.1.0"
implementation "androidx.core:core:1.1.0"
implementation "androidx.media:media:1.1.0"
implementation 'androidx.activity:activity:1.4.0'
implementation "androidx.activity:activity:1.4.0"
implementation('com.google.android.exoplayer:extension-okhttp:2.18.1') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation 'com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}'
implementation "com.squareup.okhttp3:okhttp:" + '$OKHTTP_VERSION'
}

View File

@@ -178,6 +178,7 @@ class ReactExoplayerView extends FrameLayout implements
private Dynamic textTrackValue;
private ReadableArray textTracks;
private boolean disableFocus;
private boolean focusable = true;
private boolean disableBuffering;
private long contentStartTime = -1L;
private boolean disableDisconnectError;
@@ -272,6 +273,8 @@ class ReactExoplayerView extends FrameLayout implements
addView(exoPlayerView, 0, layoutParams);
exoPlayerView.setFocusable(this.focusable);
mainHandler = new Handler();
}
@@ -559,7 +562,7 @@ class ReactExoplayerView extends FrameLayout implements
}
}
}, 1);
}
private void initializePlayerCore(ReactExoplayerView self) {
@@ -1589,7 +1592,7 @@ class ReactExoplayerView extends FrameLayout implements
for (int j = 0; j < group.length; j++) {
allTracks.add(j);
}
// Valiate list of all tracks and add only supported formats
int supportedFormatLength = 0;
ArrayList<Integer> supportedTrackList = new ArrayList<Integer>();
@@ -1748,13 +1751,18 @@ class ReactExoplayerView extends FrameLayout implements
this.disableFocus = disableFocus;
}
public void setFocusable(boolean focusable) {
this.focusable = focusable;
exoPlayerView.setFocusable(this.focusable);
}
public void setBackBufferDurationMs(int backBufferDurationMs) {
Runtime runtime = Runtime.getRuntime();
long usedMemory = runtime.totalMemory() - runtime.freeMemory();
long freeMemory = runtime.maxMemory() - usedMemory;
long reserveMemory = (long)minBackBufferMemoryReservePercent * runtime.maxMemory();
if (reserveMemory > freeMemory) {
// We don't have enough memory in reserve so we will
// We don't have enough memory in reserve so we will
Log.w("ExoPlayer Warning", "Not enough reserve memory, setting back buffer to 0ms to reduce memory pressure!");
this.backBufferDurationMs = 0;
return;

View File

@@ -70,6 +70,7 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
private static final String PROP_DISABLE_FOCUS = "disableFocus";
private static final String PROP_DISABLE_BUFFERING = "disableBuffering";
private static final String PROP_DISABLE_DISCONNECT_ERROR = "disableDisconnectError";
private static final String PROP_FOCUSABLE = "focusable";
private static final String PROP_FULLSCREEN = "fullscreen";
private static final String PROP_USE_TEXTURE_VIEW = "useTextureView";
private static final String PROP_SECURE_VIEW = "useSecureView";
@@ -182,6 +183,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
if (srcUri != null) {
videoView.setRawSrc(srcUri, extension);
}
} else {
videoView.clearSrc();
}
}
}
@@ -304,6 +307,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
videoView.setDisableFocus(disableFocus);
}
@ReactProp(name = PROP_FOCUSABLE, defaultBoolean = true)
public void setFocusable(final ReactExoplayerView videoView, final boolean focusable) {
videoView.setFocusable(focusable);
}
@ReactProp(name = PROP_BACK_BUFFER_DURATION_MS, defaultInt = 0)
public void setBackBufferDurationMs(final ReactExoplayerView videoView, final int backBufferDurationMs) {
videoView.setBackBufferDurationMs(backBufferDurationMs);
@@ -384,11 +392,12 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
}
private boolean startsWithValidScheme(String uriString) {
return uriString.startsWith("http://")
|| uriString.startsWith("https://")
|| uriString.startsWith("content://")
|| uriString.startsWith("file://")
|| uriString.startsWith("asset://");
String lowerCaseUri = uriString.toLowerCase();
return lowerCaseUri.startsWith("http://")
|| lowerCaseUri.startsWith("https://")
|| lowerCaseUri.startsWith("content://")
|| lowerCaseUri.startsWith("file://")
|| lowerCaseUri.startsWith("asset://");
}
private @ResizeMode.Mode int convertToIntDef(String resizeModeOrdinalString) {