diff --git a/CHANGELOG.md b/CHANGELOG.md index f494b778..0a956d2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,15 @@ ### 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) - 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) - 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) diff --git a/Video.js b/Video.js index 71fa94a3..0a449e43 100644 --- a/Video.js +++ b/Video.js @@ -276,16 +276,20 @@ export default class Video extends Component { let uri = source.uri || ''; if (uri && uri.match(/^\//)) { uri = `file://${uri}`; - } else if (uri === '') { - return null; } if (!uri) { - console.warn('Trying to load empty source.'); + console.log('Trying to load empty source.'); } - const isNetwork = !!(uri && uri.match(/^https?:/)); - const isAsset = !!(uri && uri.match(/^(assets-library|ph|ipod-library|file|content|ms-appx|ms-appdata):/)); + const isNetwork = !!(uri && uri.match(/^https?:/i)); + 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; const RCTVideoInstance = this.getViewManagerConfig('RCTVideo'); diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index d9297a71..a4b03b58 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -183,6 +183,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager { - console.log(JSON.stringify(err)) - this.toast(true, 'error: ' + err?.error?.code) + console.log(JSON.stringify(err?.error.errorCode)) + this.toast(true, 'error: ' + err?.error.errorCode) } onEnd = () => { diff --git a/ios/Video/RCTVideo-Bridging-Header.h b/ios/Video/RCTVideo-Bridging-Header.h index ad6089be..77815e4e 100644 --- a/ios/Video/RCTVideo-Bridging-Header.h +++ b/ios/Video/RCTVideo-Bridging-Header.h @@ -1,5 +1,5 @@ #import -#import "RCTSwiftLog.h" +#import "RCTVideoSwiftLog.h" #if __has_include() #import "RCTVideoCache.h" diff --git a/ios/Video/RCTVideo.swift b/ios/Video/RCTVideo.swift index 47231a78..bc36d17d 100644 --- a/ios/Video/RCTVideo.swift +++ b/ios/Video/RCTVideo.swift @@ -219,6 +219,12 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH @objc func setSrc(_ source:NSDictionary!) { _source = VideoSource(source) + if (_source?.uri == nil || _source?.uri == "") { + DispatchQueue.global(qos: .default).async { + self._player?.replaceCurrentItem(with: nil) + } + return; + } removePlayerLayer() _playerObserver.player = nil _playerObserver.playerItem = nil diff --git a/package.json b/package.json index e242bfb4..7ce95b15 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "main": "Video.js", "license": "MIT", "author": "Community Contributors", + "homepage": "https://github.com/react-native-video/react-native-video#readme", "repository": { "type": "git", "url": "git@github.com:react-native-video/react-native-video.git"