TheWidlarzGroup / react-native-video

A <Video /> component for react-native
MIT License
7.08k stars 2.85k forks source link

PictureInPicture not work after source uri change #2916

Open MaxJadav opened 1 year ago

MaxJadav commented 1 year ago

Bug

-Video not playing in background after chang props.

Platform

Environment info

"react-native": "0.67.2" "react-native-video": "^5.2.1"

Library version: 5.2.1

Steps To Reproduce

1.Play video with uri1, goto background, pipvideo is visible. 2.Open app again. on next change uri2 3.uri2 video is playing, Goto background, pipvideo not display.

Expected behaviour

1.On video uri change 2.Goto background pipvideo should be display.

Reproducible sample code

<Video ref={videoRef} paused={false} source={{ uri: props.videoUrl, }} controls pictureInPicture resizeMode="contain" onLoad={meta => console.log(meta)} style={{ position: 'absolute', top: 0, left: 0, right: 0, bottom: 0, }} />

Seems like issue in RCTVideo.m When this setSrc call second time: (void)setSrc:(NSDictionary *)source -> removePlayerLayer but not remove refrence _pipController.

In this function delegate not set with updated _playerLayer

- (void)setupPipController {
  if (!_pipController && _playerLayer && [AVPictureInPictureController isPictureInPictureSupported]) {
    // Create new controller passing reference to the AVPlayerLayer
    _pipController = [[AVPictureInPictureController alloc] initWithPlayerLayer:_playerLayer];
    _pipController.delegate = self;
  }
}
freeboub commented 1 year ago

Seems duplicated of https://github.com/react-native-video/react-native-video/issues/2746