-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Support for picture-in-picture API #5824
Comments
Simple button subclass that works: class PictureInPictureToggle extends Button {
async handleClick(event) {
let mediaElement = this.player_.el().firstChild();
// disable button during picture-in-picture switch
this.disable();
// switch picture-in-picture mode
try {
if (mediaElement !== document.pictureInPictureElement) {
// request picture-in-picture
await mediaElement.requestPictureInPicture();
} else {
// exit picture-in-picture
await document.exitPictureInPicture();
}
} catch (error) {
// notify listeners
this.player_.trigger('error', error);
} finally {
// switch completed
this.enable();
}
}
} |
It's now supported in the videojs-record plugin, e.g. Demo: https://collab-project.github.io/videojs-record/examples/picture-in-picture.html And it's really cool to see a I think PiP should be part of video.js, not just a plugin. |
Yes this should be a good feature . |
Yeah, this is definitely something we'll look into. |
Put together a really rough version to test just using the airplay icon works in Safari and Chrome not Firefox.
|
@gkatsev What is the status for this feature? I'd love to see built-in support for PiP in video.js. |
This week I'll be working on an actual roadmap for Video.js. This will definitely be on it. Unfortunately, I can't promise that it'll be prioritized over other work that we want or need to do. |
@gkatsev Thanks for the update. |
Any updates on this.... |
This is on the team's backlog but, unfortunately, there's a lot of work that is higher priority (https://github.com/videojs/http-streaming/milestone/3 and more). |
@gkatsev I'd love to help actually. Please write down requirements in this issue and I'll start working on it. |
Below is the req for it. I think it can be done in at least 4 stages, it's better to have it done in many PRs rather than one giant PR. Also, I'd wait a couple of days before starting so that people can add comments on the req below (feel free to add comments yourself as well) and I'll update as necessary. I think this can be done in a few stages:
add the correct API methodsThe spec is here: https://wicg.github.io/picture-in-picture
support both the spec and custom implementations (this is for Safari as they aren't spec compliant yet)Safari has their own implementation. For it, we need to update the
support the auto pip and disable pip optionsAdd add in a control bar buttonThis button should function similarly to the fullscreen toggle button
|
Also, feel free to drop by our slack for more real-time chat :) |
I've started implemented Picture-in-Picture. You should see some PRs popping up soon. For info, I wrote https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture ;) |
@beaufortfrancois hahaha, I totally didn't make the connection, super appreciate the help! |
Following #5824, this PR adds support for some Picture-in-Picture methods described in the spec and article. It also makes sure that we can listen to the enterpictureinpicture and leavepictureinpicture events on the player.
Adds a new PictureInPictureToggle component in the controls bar of the player. It depends on videojs-font 3.2.0 (videojs/font#41) for icons. Final spec piece from #5824.
what's the status of this? does 7.6.0 contain all functionality? |
7.6 contains the button and the WICG-specced API. It won't work in Safari currently, but that could be added at a later date (or safari could ship the WICG API). |
@osamaalnuimi Subtitles are not supported yet in Picture-in-Picture in Chrome. They are in Safari though. |
Thanks for the answer @beaufortfrancois! At some point, video.js will need to switch over to native text tracks when captions in PiP is supported (or at least switch to native tracks when using the PiP). Right now, native support is severely lacking (something I'm trying to fix). |
@gkatsev I noticed the PiP button is always visible but disabled in browsers that do no support it. Is this intentional? I find it kind of confusing and rather hide it in places where it's unsupported. I can do this manually of course but I wonder why a non-functional button is part of the controlbar in some browsers. |
Yeah, I think it's an oversight, it makes sense to leave it out on browsers that don't support it at all and have it be disabled if the iframe/page disables it. |
Firefox 69 Beta enables PiP but for windows only: https://hacks.mozilla.org/2019/07/testing-picture-in-picture-for-videos-in-firefox-69/ |
So is there a method for disabling picture in picture? I'm not seeing anything here: https://docs.videojs.com/tutorial-options.html |
@MrWiLofDoom you can pass in the following option to hide the button: #6002 (comment) |
Please add:
to the docs at: https://docs.videojs.com/docs/guides/options.html -- Ah, found it here: https://docs.videojs.com/docs/guides/components.html |
Description
Chrome 70+ introduces the picture-in-picture API. Would be cool to have an extra button in the player for this, allowing you to switch to PIP.
Demo: https://googlechrome.github.io/samples/picture-in-picture/
API: https://developers.google.com/web/updates/2018/10/watch-video-using-picture-in-picture and https://wicg.github.io/picture-in-picture/
Status: https://github.com/WICG/picture-in-picture/blob/master/implementation-status.md
Icon: https://material.io/tools/icons/?search=pic&icon=picture_in_picture&style=baseline
The text was updated successfully, but these errors were encountered: