chaimPaneth / react-native-jw-media-player

React-Native Android/iOS bridge for JWPlayer SDK (https://www.jwplayer.com/)
MIT License
197 stars 92 forks source link

Custom Controls not showing up when in fullscreen (iOS) #267

Open clint-gitahi opened 1 year ago

clint-gitahi commented 1 year ago

I built custom controls which is a View that shows on top of jwplayer(when use is not fullscreen). The custom controls view has a play/pause, back button, setfullscreen, captions and audio tracks selection. It works well when user has not setFullscreen. The issue i'm having is when i click the setfullscreen button the video goes full screen but i loose my view that has the controls. Below is how I implemented the setfullscreen on iOS, which works well. I had to patch it in. Question is how can i show the view with custom controls when the jw player goes fullscreen.

RCT_EXPORT_METHOD(setFullscreen: (nonnull NSNumber *)reactTag: (BOOL)fullscreen) {
    [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RNJWPlayerView *> *viewRegistry) {
        RNJWPlayerView *view = viewRegistry[reactTag];
        if (![view isKindOfClass:[RNJWPlayerView class]] || (view.playerViewController == nil && view.playerView == nil)) {
            RCTLogError(@"Invalid view returned from registry, expecting RNJWPlayerView, got: %@", view);
        } else {
             if (view.playerViewController) {
                if (fullscreen) {
                    [view.playerViewController transitionToFullScreenAnimated:TRUE completion:^{
                        NSLog(@"ENTERED FULLSCREEN");
                    }];
                } else {
                    [view.playerViewController dismissFullScreenAnimated:TRUE completion:^{
                        NSLog(@"DISMISS FULL SCREEN");
                    }];
                }
            }
        }
    }];
}