TheWidlarzGroup / react-native-video

A <Video /> component for react-native
https://docs.thewidlarzgroup.com/react-native-video/
MIT License
7.2k stars 2.9k forks source link

Picture in Picture (PIP) callbacks don't fire on restoration from a full-screen PIP #2278

Closed jcarioti closed 2 years ago

jcarioti commented 3 years ago

Bug

When launching picture in picture in iOS, there are two modes: PIP mode directly from the current viewer, and fullscreen PIP mode where you launch into fullscreen, and then press the PIP button from there.

I've noticed some different functionality between the two:

  1. in fullscreen PIP mode, both videos play: the PIP as well as the original video frame.
  2. in pure PIP mode, only the PIP plays while the original video frame shows a message about PIP
  3. in pure PIP mode, the onPictureInPictureStatusChanged callback fires appropriately
  4. in fullscreen PIP mode, the callback never fires either on PIP start or PIP end.

I noticed someone saw this before the feature went in here: https://github.com/react-native-video/react-native-video/pull/1325#issuecomment-464998645

Platform

Which player are you experiencing the problem on:

Environment info

React native info output:

System:
    OS: macOS 10.15.7
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    Memory: 719.15 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
    Yarn: 1.22.5 - ~/.yarn/bin/yarn
    npm: 6.14.8 - ~/.nvm/versions/node/v12.18.2/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.0 AI-193.6911.18.40.6626763
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^16.13.1 => 16.13.1 
    react-native: 0.63.2 => 0.63.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 5.1.1

Steps To Reproduce

  1. Play an HLS stream
  2. Enter fullscreen
  3. Enter PIP mode from fullscreen
  4. Restore PIP to app

Expected behaviour

  1. The onPictureInPictureStatusChanged callbacks fire as the PIP starts and ends from the context of the fullscreen viewer

Reproducible sample code

 <Video
          source={{ uri: 'someHlsStream.m3u8' }}
          muted
          fullscreen
          playInBackground
          ignoreSilentSwitch="ignore"
          onPictureInPictureStatusChanged={({ isActive }) => {
            console.log('PIP is', isActive );
          }}
          onRestoreUserInterfaceForPictureInPictureStop={() => {
            console.log('on restore from PIP');
            videoRef.current?.restoreUserInterfaceForPictureInPictureStopCompleted(true);
          }}
          onFullscreenPlayerWillDismiss={() => {
            console.log('player dismissing')
          }}
          onFullscreenPlayerDidDismiss={() => {
            console.log('player dismissed');
          }}
        />

Video sample

Any HLS m3u8 stream.

fielddaychurch commented 3 years ago

I am running into the exact same issue. (watching)

megabayt commented 2 years ago

Same issue. Steps to reproduce:

1) Enter fullscreen 2) Go to home screen or press PiP icon 3) It should fire onPictureInPictureStatusChanged event

When you manually change pictureInPicture property event is fired.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are having a similar problem, please open a new issue and reference this one instead of commenting on a stale or closed issue.