From 04157baeb53ba8db64771751546bc442edb3291c Mon Sep 17 00:00:00 2001 From: Jatin Nagar Date: Mon, 27 Mar 2023 22:28:22 +0530 Subject: [PATCH 1/6] feat: added option to change error message --- VideoPlayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VideoPlayer.js b/VideoPlayer.js index 3ee8323..09f95a4 100644 --- a/VideoPlayer.js +++ b/VideoPlayer.js @@ -1199,7 +1199,7 @@ export default class VideoPlayer extends Component { source={require('./assets/img/error-icon.png')} style={styles.error.icon} /> - Video unavailable + {this.props.errorMessage || 'Video unavailable'} ); } From 3ae73b3b1d1b927f5cde19a7f1228ebf18c0d5a9 Mon Sep 17 00:00:00 2001 From: Jatin Nagar Date: Mon, 27 Mar 2023 22:33:52 +0530 Subject: [PATCH 2/6] feat: added option to handle errors user can handle error thrown from `react-native-video` while also keeping error handling mechanism provided by `react-native-video-controls` lib --- VideoPlayer.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VideoPlayer.js b/VideoPlayer.js index 09f95a4..264a3d3 100644 --- a/VideoPlayer.js +++ b/VideoPlayer.js @@ -285,6 +285,10 @@ export default class VideoPlayer extends Component { state.loading = false; this.setState(state); + + if (typeof this.props.catchError === "function") { + this.props.catchError(err); + } } /** From f285f74dc8129cdd7c891e11ce03b7d75a8f2b35 Mon Sep 17 00:00:00 2001 From: Jatin Nagar Date: Mon, 27 Mar 2023 22:45:01 +0530 Subject: [PATCH 3/6] type definitions for `catchError` & `errorMessage` --- VideoPlayer.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/VideoPlayer.d.ts b/VideoPlayer.d.ts index 0fe686b..5eb689d 100644 --- a/VideoPlayer.d.ts +++ b/VideoPlayer.d.ts @@ -29,6 +29,8 @@ interface VideoPlayerProperties extends VideoProperties { style?: StyleProp; /** If true, single tapping anywhere on the video (other than a control) toggles between playing and paused. */ tapAnywhereToPause?: boolean; + /** Custom error message to show in Video Player UI */ + errorMessage?: string; /** Fired when the video enters fullscreen after the fullscreen button is pressed */ onEnterFullscreen?: () => void; /** Fired when the video exits fullscreen after the fullscreen button is pressed */ @@ -37,8 +39,10 @@ interface VideoPlayerProperties extends VideoProperties { onHideControls?: () => void; /** Fired when the controls appear */ onShowControls?: () => void; - /** Fired when an error is encountered when loading the video */ + /** Fired when an error is encountered when loading the video. This overrides error handling mechanism provided by react-native-video-controls lib */ onError?: (error: LoadError) => void; + /** Fired when an error is encountered when loading the video. This does not overrides error handling mechanism provided by react-native-video-controls lib */ + catchError?: (error: LoadError) => void; /** Fired when the video is paused after the play/pause button is pressed */ onPause?: () => void; /** Fired when the video begins playing after the play/pause button is pressed */ From a2daf48d6f8235eb63f77b5361d273857877af40 Mon Sep 17 00:00:00 2001 From: Jatin Nagar Date: Mon, 27 Mar 2023 23:01:51 +0530 Subject: [PATCH 4/6] added `catchError` & `errorMessage` prop docs also fixed `showTimeRemaining` and `showHours` prop doc styling --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e43d8f6..69cb1ea 100644 --- a/README.md +++ b/README.md @@ -68,12 +68,9 @@ In addition, the `` also takes these props: | seekColor | String(#HEX) | '#FFF' | Fill/handle colour of the seekbar | | style | StyleSheet | null | React Native StyleSheet object that is appended to the video's parent `` | | tapAnywhereToPause | Boolean | false | If true, single tapping anywhere on the video (other than a control) toggles between playing and paused. | - -| showTimeRemaining | Boolean | true | If true, show the time remaing, else show the current time in the Player. -`` - -| showHours | Boolean | false | If true, convert time to hours in the Player -`` +| showTimeRemaining | Boolean | true | If true, show the time remaining, else show the current time in the Player `` | +| showHours | Boolean | false | If true, convert time to hours in the Player `` | +| errorMessage | String | 'Video unavailable' | Error message to show in Video Player UI when error occurs | ### Events @@ -85,7 +82,8 @@ These are various events that you can hook into and fire functions on in the com | onExitFullscreen | Fired when the video exits fullscreen after the fullscreen button is pressed | | onHideControls | Fired when the controls disappear | | onShowControls | Fired when the controls appear | -| onError | Fired when an error is encountered when loading the video | +| onError | Fired when an error is encountered when loading the video. This prop overrides error handling mechanism provided by this library | +| catchError | Fired when an error is encountered when loading the video | | onPause | Fired when the video is paused after the play/pause button is pressed | | onPlay | Fired when the video begins playing after the play/pause button is pressed | | onBack | Function fired when back button is pressed, override if using custom navigation | From ea530be508bdb394153c9cb4d3615cea673226f5 Mon Sep 17 00:00:00 2001 From: Jatin Nagar Date: Mon, 27 Mar 2023 23:09:34 +0530 Subject: [PATCH 5/6] Upgraded library version only minor version upgrade needed as their is no breaking change --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 574def6..fae6f3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-video-controls", - "version": "2.8.1", + "version": "2.9.1", "description": "A set of GUI controls for the react-native-video component", "license": "MIT", "main": "VideoPlayer.js", From 3107df952bc38277ea771df265fe7c69d9269da9 Mon Sep 17 00:00:00 2001 From: Jatin Nagar Date: Mon, 27 Mar 2023 23:15:08 +0530 Subject: [PATCH 6/6] added v2.9.1 change logs --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0289f3f..08bf153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 2.9.1 (27-03-2023) + +Added `errorMessage` prop to customize error message shown in Video Player UI + +Added `catchError` prop to handle `react-native-video` lib error while also using error handling mechanism provided by `react-native-video-controls` lib + ## 2.5.1 (17-05-2020) [#177](https://github.com/itsnubix/react-native-video-controls/pull/177)