'Child view controller <JWPlayerKit.JWplayerViewController> should have parent view controller <RNSScreen> but actual parent is <UIViewController>
I'm attempting to implement JWPlayer SDK v4 into a React Native ios app using the library [email protected].
If the player screen is the initial screen shown on app load, the player embeds without any issues, however when navigating away from and back to the player screen (using react-navigation tabs), the following exception is thrown:
Exception thrown while executing UI block: child view controller:<JWPlayerKit.JWPlayerViewController: 0x7fd744bab800> should have parent view controller:<RNSScreen: 0x7fd6db935310> but actual parent is:<UIViewController: 0x7fd745a057a0>
I am new to mobile development (coming from React) and have spent countless hours trying to resolve this but am not getting anywhere so any help is massively appreciated!
Solution 1:[1]
While it's not exactly a fix, I managed to work around this issue by creating a hidden <JWPlayer> component and added it to App.js. Now any subsequent instances of <JWPlayer> work as expected.
Here's the hidden player component:
export default function HiddenPlayer() {
const player = useRef(null);
return (
<View>
<JWPlayer
ref={player}
style={styles.video}
config={...config}
/>
</View>
);
}
const styles = StyleSheet.create({
video: {
display: 'none',
},
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JRedford |

