Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for "picture in picture" #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jose-nunez
Copy link
Collaborator

I tried adding unit tests, but it seems like the TS transpiler (ts-react-toolbox) has an outdated TS version and thus, it does not support PictureInPicture API.
I didn't take the time to see how to upgrade the underlying tooling. Maybe @zzarcon can have a look at that?

yarn test __tests__/index.tsx
yarn run v1.22.19
$ ts-react-toolbox test __tests__/index.tsx
 FAIL  __tests__/index.tsx
  ● Test suite failed to run

    src/video.tsx:262:29 - error TS2339: Property 'pictureInPictureElement' does not exist on type 'Document'.

    262     return !!getDocument()?.pictureInPictureElement;
                                    ~~~~~~~~~~~~~~~~~~~~~~~
    src/video.tsx:267:29 - error TS2339: Property 'pictureInPictureEnabled' does not exist on type 'Document'.

    267     return !!getDocument()?.pictureInPictureEnabled && sourceType === 'video';
                                    ~~~~~~~~~~~~~~~~~~~~~~~
    src/video.tsx:271:53 - error TS2339: Property 'exitPictureInPicture' does not exist on type 'Document'.

    271     this.isPictureInPictureActive && getDocument()?.exitPictureInPicture();
                                                            ~~~~~~~~~~~~~~~~~~~~
    src/video.tsx:280:36 - error TS2339: Property 'requestPictureInPicture' does not exist on type 'HTMLVideoElement'.

    280       await this.videoRef.current?.requestPictureInPicture();
                                           ~~~~~~~~~~~~~~~~~~~~~~~

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.193 s
Ran all test suites matching /__tests__\/index.tsx/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command

}
try {
// If the binary hasn't been loaded yet, this can throw an error
await this.videoRef.current?.requestPictureInPicture();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having a retry mechanism? aka, try again when the video finish loading

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, not binary fully loaded, but the first bytes (i.e. no internet connection or similar).
The component should fall into an error state in these cases. Therefore, no need to auto retry here, I believe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants