From 3f44d6ee253ab527ad914360079df2000a5c9563 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Wed, 14 Sep 2022 21:57:37 +0200 Subject: [PATCH] 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');