The plugin provides an error handling API via which the App can be provided with details of errors that have occurred.
See the React Native SDK APIs for full details - especially in this case the onError
event and the error codes that can be reported with that event.
Error Types
There are several error types that classify the set of errors into different categories of Player functionality, for example
- Media type error
- DRM type error
- SSM type error
The full list of errors and their types is documented in React Native SDK APIs.
Example Code
Click here to see a minimal implementation to log errors
CODE
…
import OTVPlayer from '@nagra/react-otvplayer'
…
const App: () => Node = () => {
…
this.otvplayer = {
ref: OTVPlayer
};
this._onError = (eventData) => {
console.log(`Error witnessed ${JSON.stringify(eventData)}`);
};
this.events = {
onError: this._onError.bind(this)
};
return (
<OTVPlayer
// You will need to retain a reference to the OTVPlayer element in order to interact with the playback on user events
ref={otvplayer => this.otvplayer.ref = otvplayer}
// A source can be specified in the element declaration or programmatically, specifying it in here starts the content loading immediately
source={{
src: "https://d3bqrzf9w11pn3.cloudfront.net/basic_hls_bbb_clear/index.m3u8"
type: "application/x-mpegURL",
}}
// There are several playback events that can be hooked in to and trigger actions in the application
onError={this.events.onError}
>
</OTVPlayer>
);
…
}
…