Merge branch 'master' into fix-ios-rctswiftlog-collision

This commit is contained in:
Liam Potter 2022-09-28 22:31:37 +01:00 committed by GitHub
commit d0544c3531
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 7 deletions

9
API.md
View File

@ -277,6 +277,7 @@ var styles = StyleSheet.create({
|[disableDisconnectError](#disableDisconnectError)|Android| |[disableDisconnectError](#disableDisconnectError)|Android|
|[filter](#filter)|iOS| |[filter](#filter)|iOS|
|[filterEnabled](#filterEnabled)|iOS| |[filterEnabled](#filterEnabled)|iOS|
|[focusable](#focusable)|Android|
|[fullscreen](#fullscreen)|iOS| |[fullscreen](#fullscreen)|iOS|
|[fullscreenAutorotate](#fullscreenautorotate)|iOS| |[fullscreenAutorotate](#fullscreenautorotate)|iOS|
|[fullscreenOrientation](#fullscreenorientation)|iOS| |[fullscreenOrientation](#fullscreenorientation)|iOS|
@ -486,6 +487,14 @@ Enable video filter.
Platforms: iOS Platforms: iOS
#### Focusable
Whether this video view should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
* **false** - Makes view unfocusable
* **true (default)** - Makes view focusable
Platforms: Android
#### fullscreen #### fullscreen
Controls whether the player enters fullscreen on play. Controls whether the player enters fullscreen on play.
* **false (default)** - Don't display the video in fullscreen * **false (default)** - Don't display the video in fullscreen

View File

@ -1,8 +1,10 @@
## Changelog ## Changelog
### Version 6.0.0-alpha4 ### Version 6.0.0-alpha4
- Android: Switch Google's maven repository to default `google()` [#2860](https://github.com/react-native-video/react-native-video/pull/2860) - Android: Switch Google's maven repository to default `google()` [#2860](https://github.com/react-native-video/react-native-video/pull/2860)
- Android: Implement focusable prop so the video view can toggle whether it is focusable for non-touch devices [#2819](https://github.com/react-native-video/react-native-video/issues/2819)
- Fix iOS RCTSwiftLog naming collision [#2868](https://github.com/react-native-video/react-native-video/issues/2868) - Fix iOS RCTSwiftLog naming collision [#2868](https://github.com/react-native-video/react-native-video/issues/2868)
### Version 6.0.0-alpha3 ### Version 6.0.0-alpha3
- Fix ios build [#2854](https://github.com/react-native-video/react-native-video/pull/2854) - Fix ios build [#2854](https://github.com/react-native-video/react-native-video/pull/2854)

View File

@ -1,15 +1,27 @@
# react-native-video # react-native-video
#### A `<Video>` component for react-native. > :warning: **Version 6 Alpha**: The following documentation may refer to features only available through the v6.0.0 alpha releases, [please see version 5.2.x](https://github.com/react-native-video/react-native-video/blob/v5.2.0/README.md) for the current documentation!
Version 6.x recommends react-native >= 0.68.2. For older versions of react-native, [please use version 5.x](https://github.com/react-native-video/react-native-video/tree/v5.2.0). ## A `<Video>` component for react-native.
Version 6.x recommends react-native >= 0.68.2.
<br>For older versions of react-native, [please use version 5.x](https://github.com/react-native-video/react-native-video/tree/v5.2.0).
### Version 6.0.0 breaking changes ### Version 6.0.0 breaking changes
Version 6.0.0 is introducing dozens of breaking changes, mostly through updated dependecies and significant refactoring. While the API remains compatible, the significant internal changes require full testing with your app to ensure all functionality remains operational. Please view the [Changelog](CHANGELOG.md) for specific breaking changes. Version 6.0.0 is introducing dozens of breaking changes, mostly through updated dependecies and significant refactoring. While the API remains compatible, the significant internal changes require full testing with your app to ensure all functionality remains operational. Please view the [Changelog](CHANGELOG.md) for specific breaking changes.
## Useful resources ### Installing Version 6.0.0 Alphas
Whilst we finalise version 6.0.0 you can install the latest alpha from npm
Using npm:
```
npm install --save react-native-video@alpha
```
using yarn:
```
yarn add react-native-video@alpha
```
## Useful resources
- [Documentation](API.md) - [Documentation](API.md)
- [Changelog](CHANGELOG.md) - [Changelog](CHANGELOG.md)
- [Contribution guide](CONTRIBUTING.md) - [Contribution guide](CONTRIBUTING.md)

View File

@ -483,6 +483,7 @@ Video.propTypes = {
reportBandwidth: PropTypes.bool, reportBandwidth: PropTypes.bool,
contentStartTime: PropTypes.number, contentStartTime: PropTypes.number,
disableFocus: PropTypes.bool, disableFocus: PropTypes.bool,
focusable: PropTypes.bool,
disableBuffering: PropTypes.bool, disableBuffering: PropTypes.bool,
controls: PropTypes.bool, controls: PropTypes.bool,
audioOnly: PropTypes.bool, audioOnly: PropTypes.bool,

View File

@ -190,6 +190,7 @@ class ReactExoplayerView extends FrameLayout implements
private Dynamic textTrackValue; private Dynamic textTrackValue;
private ReadableArray textTracks; private ReadableArray textTracks;
private boolean disableFocus; private boolean disableFocus;
private boolean focusable = true;
private boolean disableBuffering; private boolean disableBuffering;
private long contentStartTime = -1L; private long contentStartTime = -1L;
private boolean disableDisconnectError; private boolean disableDisconnectError;
@ -284,6 +285,8 @@ class ReactExoplayerView extends FrameLayout implements
addView(exoPlayerView, 0, layoutParams); addView(exoPlayerView, 0, layoutParams);
exoPlayerView.setFocusable(this.focusable);
mainHandler = new Handler(); mainHandler = new Handler();
} }
@ -571,7 +574,7 @@ class ReactExoplayerView extends FrameLayout implements
} }
} }
}, 1); }, 1);
} }
private void initializePlayerCore(ReactExoplayerView self) { private void initializePlayerCore(ReactExoplayerView self) {
@ -1119,7 +1122,7 @@ class ReactExoplayerView extends FrameLayout implements
WritableArray videoTracks = Arguments.createArray(); WritableArray videoTracks = Arguments.createArray();
MappingTrackSelector.MappedTrackInfo info = trackSelector.getCurrentMappedTrackInfo(); MappingTrackSelector.MappedTrackInfo info = trackSelector.getCurrentMappedTrackInfo();
if (info == null || trackRendererIndex == C.INDEX_UNSET) { if (info == null || trackRendererIndex == C.INDEX_UNSET) {
return videoTracks; return videoTracks;
} }
@ -1578,7 +1581,7 @@ class ReactExoplayerView extends FrameLayout implements
for (int j = 0; j < group.length; j++) { for (int j = 0; j < group.length; j++) {
allTracks.add(j); allTracks.add(j);
} }
// Valiate list of all tracks and add only supported formats // Valiate list of all tracks and add only supported formats
int supportedFormatLength = 0; int supportedFormatLength = 0;
ArrayList<Integer> supportedTrackList = new ArrayList<Integer>(); ArrayList<Integer> supportedTrackList = new ArrayList<Integer>();
@ -1737,13 +1740,18 @@ class ReactExoplayerView extends FrameLayout implements
this.disableFocus = disableFocus; this.disableFocus = disableFocus;
} }
public void setFocusable(boolean focusable) {
this.focusable = focusable;
exoPlayerView.setFocusable(this.focusable);
}
public void setBackBufferDurationMs(int backBufferDurationMs) { public void setBackBufferDurationMs(int backBufferDurationMs) {
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
long usedMemory = runtime.totalMemory() - runtime.freeMemory(); long usedMemory = runtime.totalMemory() - runtime.freeMemory();
long freeMemory = runtime.maxMemory() - usedMemory; long freeMemory = runtime.maxMemory() - usedMemory;
long reserveMemory = (long)minBackBufferMemoryReservePercent * runtime.maxMemory(); long reserveMemory = (long)minBackBufferMemoryReservePercent * runtime.maxMemory();
if (reserveMemory > freeMemory) { 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!"); Log.w("ExoPlayer Warning", "Not enough reserve memory, setting back buffer to 0ms to reduce memory pressure!");
this.backBufferDurationMs = 0; this.backBufferDurationMs = 0;
return; 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_FOCUS = "disableFocus";
private static final String PROP_DISABLE_BUFFERING = "disableBuffering"; private static final String PROP_DISABLE_BUFFERING = "disableBuffering";
private static final String PROP_DISABLE_DISCONNECT_ERROR = "disableDisconnectError"; 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_FULLSCREEN = "fullscreen";
private static final String PROP_USE_TEXTURE_VIEW = "useTextureView"; private static final String PROP_USE_TEXTURE_VIEW = "useTextureView";
private static final String PROP_SECURE_VIEW = "useSecureView"; private static final String PROP_SECURE_VIEW = "useSecureView";
@ -304,6 +305,11 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
videoView.setDisableFocus(disableFocus); 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) @ReactProp(name = PROP_BACK_BUFFER_DURATION_MS, defaultInt = 0)
public void setBackBufferDurationMs(final ReactExoplayerView videoView, final int backBufferDurationMs) { public void setBackBufferDurationMs(final ReactExoplayerView videoView, final int backBufferDurationMs) {
videoView.setBackBufferDurationMs(backBufferDurationMs); videoView.setBackBufferDurationMs(backBufferDurationMs);