jwplayer / jwplayer-react-native

MIT License
32 stars 9 forks source link

[BUG]onPlayerError/onSetupPlayer error are not being called on native side or they do not expose any error codes via bridge #63

Closed fdobre closed 1 month ago

fdobre commented 4 months ago

Description

"@jwplayer/jwplayer-react-native": "^1.0.1",
"react-native": "0.72.14"

Android: onPlayerError/onSetupPlayer are not called when there is an error regarding the hlsUrl or the signature token.

iOS: - when there is a video play error (invalid hls url or expired token) onPlayerError is not called. Instead, the onSetupPlayerError is called and event?.nativeEvent does not contain enough data for error handling in react native:

// event?.nativeEvent:
{"error": "This video file cannot be played.", "target": 7355}

Object should contain the error code. In case token is expired a fetch from BE could be done to obtain a new valid hlsUrl

To Reproduce

  1. Use an invalid hlsUrl (one that gives a 404) or use an expired signature.
  2. Add onSetupPlayerError and onError functions:
       onSetupPlayerError={(event: NativeError) => {
              console.log('=====setup error====', event?.nativeEvent);
       }}
      onPlayerError={(event: NativeError) => {
              console.log('=====error====', event?.nativeEvent);
      }
  1. Observe there are no logs on Android and on iOS there is no information about the error code.

Expected behavior In case of any player or setup error at least one of the error functions should be called and the error code should be exposed in the nativeEvent object.

Screenshots / Visual evidence

Player displays error codes but these are not included in the nativeEvent or the onError functions are not being called. Screenshot 2024-07-23 at 14 44 19

Jmilham21 commented 1 month ago

This should be resolved in the main branch now as of merging https://github.com/jwplayer/jwplayer-react-native/pull/96. This will be packed into the next release to NPM.