Merge branch 'master' into chore/fix_lintter_warning

This commit is contained in:
Olivier Bouillet 2022-10-16 15:40:21 +02:00 committed by GitHub
commit f25308bc06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 15 deletions

View File

@ -2,13 +2,15 @@
### Version 6.0.0-alpha.4 ### Version 6.0.0-alpha.4
- ensure src is always provided to native player even if it is invalid [#2857](https://github.com/react-native-video/react-native-video/pull/2857)
- Sample: Add react-native-video controls support [#2852](https://github.com/react-native-video/react-native-video/pull/2852) - Sample: Add react-native-video controls support [#2852](https://github.com/react-native-video/react-native-video/pull/2852)
- 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) - 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)
- Android: fix linter warning [#2891] (https://github.com/react-native-video/react-native-video/pull/2891) - Android: fix linter warning [#2891] (https://github.com/react-native-video/react-native-video/pull/2891)
- Fix iOS RCTSwiftLog naming collision [#2868](https://github.com/react-native-video/react-native-video/issues/2868)
- Added "homepage" to package.json [#2882](https://github.com/react-native-video/react-native-video/pull/2882)
### Version 6.0.0-alpha3 ### Version 6.0.0-alpha.3
- 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

@ -276,16 +276,20 @@ export default class Video extends Component {
let uri = source.uri || ''; let uri = source.uri || '';
if (uri && uri.match(/^\//)) { if (uri && uri.match(/^\//)) {
uri = `file://${uri}`; uri = `file://${uri}`;
} else if (uri === '') {
return null;
} }
if (!uri) { if (!uri) {
console.warn('Trying to load empty source.'); console.log('Trying to load empty source.');
} }
const isNetwork = !!(uri && uri.match(/^https?:/)); const isNetwork = !!(uri && uri.match(/^https?:/i));
const isAsset = !!(uri && uri.match(/^(assets-library|ph|ipod-library|file|content|ms-appx|ms-appdata):/)); const isAsset = !!(uri && uri.match(/^(assets-library|ph|ipod-library|file|content|ms-appx|ms-appdata):/i));
if ((uri || uri === '') && !isNetwork && !isAsset) {
if (this.props.onError) {
this.props.onError({error: {errorString: 'invalid url, player will stop', errorCode: 'INVALID_URL'}});
}
}
let nativeResizeMode; let nativeResizeMode;
const RCTVideoInstance = this.getViewManagerConfig('RCTVideo'); const RCTVideoInstance = this.getViewManagerConfig('RCTVideo');

View File

@ -183,6 +183,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
if (srcUri != null) { if (srcUri != null) {
videoView.setRawSrc(srcUri, extension); videoView.setRawSrc(srcUri, extension);
} }
} else {
videoView.clearSrc();
} }
} }
} }
@ -390,11 +392,12 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
} }
private boolean startsWithValidScheme(String uriString) { private boolean startsWithValidScheme(String uriString) {
return uriString.startsWith("http://") String lowerCaseUri = uriString.toLowerCase();
|| uriString.startsWith("https://") return lowerCaseUri.startsWith("http://")
|| uriString.startsWith("content://") || lowerCaseUri.startsWith("https://")
|| uriString.startsWith("file://") || lowerCaseUri.startsWith("content://")
|| uriString.startsWith("asset://"); || lowerCaseUri.startsWith("file://")
|| lowerCaseUri.startsWith("asset://");
} }
private @ResizeMode.Mode int convertToIntDef(String resizeModeOrdinalString) { private @ResizeMode.Mode int convertToIntDef(String resizeModeOrdinalString) {

View File

@ -68,6 +68,12 @@ class VideoPlayer extends Component {
'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0', 'http://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0',
type: 'mpd', type: 'mpd',
}, },
{
description: 'invalid URL',
uri:
'mmt://www.youtube.com',
type: 'mpd',
},
{ description: '(no url) Stopped playback', uri: undefined }, { description: '(no url) Stopped playback', uri: undefined },
{ {
description: '(no view) no View', description: '(no view) no View',
@ -247,8 +253,8 @@ class VideoPlayer extends Component {
} }
onError = (err: any) => { onError = (err: any) => {
console.log(JSON.stringify(err)) console.log(JSON.stringify(err?.error.errorCode))
this.toast(true, 'error: ' + err?.error?.code) this.toast(true, 'error: ' + err?.error.errorCode)
} }
onEnd = () => { onEnd = () => {

View File

@ -1,5 +1,5 @@
#import <React/RCTViewManager.h> #import <React/RCTViewManager.h>
#import "RCTSwiftLog.h" #import "RCTVideoSwiftLog.h"
#if __has_include(<react-native-video/RCTVideoCache.h>) #if __has_include(<react-native-video/RCTVideoCache.h>)
#import "RCTVideoCache.h" #import "RCTVideoCache.h"

View File

@ -219,6 +219,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
@objc @objc
func setSrc(_ source:NSDictionary!) { func setSrc(_ source:NSDictionary!) {
_source = VideoSource(source) _source = VideoSource(source)
if (_source?.uri == nil || _source?.uri == "") {
DispatchQueue.global(qos: .default).async {
self._player?.replaceCurrentItem(with: nil)
}
return;
}
removePlayerLayer() removePlayerLayer()
_playerObserver.player = nil _playerObserver.player = nil
_playerObserver.playerItem = nil _playerObserver.playerItem = nil

View File

@ -5,6 +5,7 @@
"main": "Video.js", "main": "Video.js",
"license": "MIT", "license": "MIT",
"author": "Community Contributors", "author": "Community Contributors",
"homepage": "https://github.com/react-native-video/react-native-video#readme",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git@github.com:react-native-video/react-native-video.git" "url": "git@github.com:react-native-video/react-native-video.git"