From 3f44d6ee253ab527ad914360079df2000a5c9563 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Wed, 14 Sep 2022 21:57:37 +0200 Subject: [PATCH 01/12] fix: ensure player receive uri update event if the uri is empty --- Video.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Video.js b/Video.js index 287573a1..e068c84d 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 && !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'); From f31e47f36007a3d75f76eb454b051597bd9d12df Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Wed, 14 Sep 2022 21:58:17 +0200 Subject: [PATCH 02/12] fix(exoplayer): ensure player is stopped when invalid uri is configured --- .../com/brentvatne/exoplayer/ReactExoplayerViewManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index ce1d6a8c..cd9fc222 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -182,6 +182,8 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Wed, 14 Sep 2022 21:58:39 +0200 Subject: [PATCH 03/12] fix(exoplayer): allow uri to high case --- .../exoplayer/ReactExoplayerViewManager.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java index cd9fc222..7b6f1dd4 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerViewManager.java @@ -386,11 +386,12 @@ public class ReactExoplayerViewManager extends ViewGroupManager Date: Wed, 14 Sep 2022 21:58:59 +0200 Subject: [PATCH 04/12] demo: update sample to support invalid uri --- examples/basic/src/VideoPlayer.android.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/basic/src/VideoPlayer.android.tsx b/examples/basic/src/VideoPlayer.android.tsx index ef53c752..727a463f 100644 --- a/examples/basic/src/VideoPlayer.android.tsx +++ b/examples/basic/src/VideoPlayer.android.tsx @@ -51,7 +51,7 @@ class VideoPlayer extends Component { require('./broadchurch.mp4'), { description: '(dash) sintel subtitles', - uri: 'https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd', + uri: 'Https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd', }, { description: '(mp4) big buck bunny', @@ -67,6 +67,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', type: 'mpd', }, + { + description: 'invalid URL', + uri: + 'mmt://www.youtube.com', + type: 'mpd', + }, { description: '(no url) Stopped playback', uri: undefined }, { description: '(no view) no View', @@ -246,8 +252,8 @@ class VideoPlayer extends Component { } onError = (err: any) => { - 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 = () => { From 32949120bfb9d979e02ae8f321b8cf6ee7e86622 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Wed, 14 Sep 2022 22:05:43 +0200 Subject: [PATCH 05/12] chore: update changeLog --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 267f52b2..a197d0a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## Changelog -### Version 6.0.0-alpha3 + +### 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) + +### Version 6.0.0-alpha.3 - fix ios build [#2854](https://gthub.com/react-native-video/react-native-video/pull/2854) ### Version 6.0.0-alpha.2 From d67b3c45b5fc01c6e4c03b8e056eaf79f1accebe Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Sun, 2 Oct 2022 21:33:03 +0200 Subject: [PATCH 06/12] fix: improve initial test for checking url validity --- Video.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Video.js b/Video.js index e9ac1466..0a449e43 100644 --- a/Video.js +++ b/Video.js @@ -285,7 +285,7 @@ export default class Video extends Component { 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 && !isNetwork && !isAsset) { + if ((uri || uri === '') && !isNetwork && !isAsset) { if (this.props.onError) { this.props.onError({error: {errorString: 'invalid url, player will stop', errorCode: 'INVALID_URL'}}); } From c197271889031f2510d4c75eafb6bfc02557ff8b Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Sun, 2 Oct 2022 21:33:24 +0200 Subject: [PATCH 07/12] chore: revert strange url in sample --- examples/basic/src/VideoPlayer.android.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/basic/src/VideoPlayer.android.tsx b/examples/basic/src/VideoPlayer.android.tsx index dba99ac5..4b426ace 100644 --- a/examples/basic/src/VideoPlayer.android.tsx +++ b/examples/basic/src/VideoPlayer.android.tsx @@ -52,7 +52,7 @@ class VideoPlayer extends Component { require('./broadchurch.mp4'), { description: '(dash) sintel subtitles', - uri: 'Https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd', + uri: 'https://bitmovin-a.akamaihd.net/content/sintel/sintel.mpd', }, { description: '(mp4) big buck bunny', From 2efa746eed85eb2b4fd1df2e119b407d9fb1b9a2 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Sun, 2 Oct 2022 21:33:53 +0200 Subject: [PATCH 08/12] fix(ios): ensure we stop playback on invalid or empty url --- ios/Video/RCTVideo.swift | 6 ++++++ 1 file changed, 6 insertions(+) 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 From 1ba3b2c526e4fabf7e6746ae179be54818e4b22c Mon Sep 17 00:00:00 2001 From: Liam Potter Date: Mon, 3 Oct 2022 13:28:30 +0100 Subject: [PATCH 09/12] Missed 1 import for RCTVideoSwiftLog This is an addendum to #2870 --- ios/Video/RCTVideo-Bridging-Header.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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" From cecb86a48e4275459bc0c288388bf25afdbfc632 Mon Sep 17 00:00:00 2001 From: Adnan Bacic Date: Tue, 4 Oct 2022 13:18:23 +0200 Subject: [PATCH 10/12] added homepage to package.json --- package.json | 1 + 1 file changed, 1 insertion(+) 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" From 187e566ee2b22cd117ddff23149810e6ce0a1d2e Mon Sep 17 00:00:00 2001 From: Adnan Bacic Date: Tue, 4 Oct 2022 13:25:49 +0200 Subject: [PATCH 11/12] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4c15931..520d9c96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - 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) +- Added "homepage" to package.json [#2868](https://github.com/react-native-video/react-native-video/pull/2882) ### Version 6.0.0-alpha.3 From bb40bba0a650755098120b92aaadc11428a51362 Mon Sep 17 00:00:00 2001 From: Adnan Bacic Date: Tue, 4 Oct 2022 13:29:55 +0200 Subject: [PATCH 12/12] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 520d9c96..b1213f3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - 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) -- Added "homepage" to package.json [#2868](https://github.com/react-native-video/react-native-video/pull/2882) +- Added "homepage" to package.json [#2882](https://github.com/react-native-video/react-native-video/pull/2882) ### Version 6.0.0-alpha.3