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

What does "Document PiP requires user activation" mean? #96

Closed
pandyama opened this issue Sep 18, 2023 · 15 comments
Closed

What does "Document PiP requires user activation" mean? #96

pandyama opened this issue Sep 18, 2023 · 15 comments

Comments

@pandyama
Copy link

I am trying to trigger the Pip window to open up on a blur event i.e when the user navigates away from the chrome tab, I want to trigger the Pip. I want to know if this is something possible? And, I wanna understand what "Document PiP requires user activation" exception means, thanks!

@steimelchrome
Copy link
Collaborator

"user activation" generally means a user clicked something on your page. You cannot currently do what you are trying to do, but Chrome is currently looking into using an 'enterpictureinpicture' MediaSessionAction to allow that scenario to happen (you would register for that action and Chrome would fire it in specific cases when a user navigates away from your tab)

@pandyama
Copy link
Author

@steimelchrome oh ok gotcha, thanks for the quick response... & where can i see the timeline for that feature's release? or if you just happen to know, that'd be good info to have

@steimelchrome
Copy link
Collaborator

We're hoping for an initial launch in M120 that would only cover cases where the website is currently using camera or microphone (so that your VC calls can automatically PiP when you go to another tab). We will follow that up with more use cases (e.g. video playback), but I'm not sure exactly when that'd be. Does your use case use camera or microphone and/or do you have a video playing when the user switches tabs?

@pandyama
Copy link
Author

@steimelchrome Yaa we use microphone for audio recording, no video for our use-case.
Also what does VC calls mean? not familiar w that short form

@steimelchrome
Copy link
Collaborator

VC stands for video conferencing, so something like Zoom. If you are using the users microphone in your use case, then you should be able to work with the initial launch (hopefully M120)

@pandyama
Copy link
Author

Thanks @steimelchrome will keep an eye out for M120's release schedule!

@steimelchrome
Copy link
Collaborator

Hey fyi in Chrome Canary 120.0.6050.0 and later, you should be able to play around with this now.

Enable the flag at chrome://flags/#media-session-enter-picture-in-picture

You can see a test page here: https://steimelchrome.github.io/autopip.html

Opening camera and then switching tabs allows the page to trigger video or document pip without user activation (there is a per-site setting for it, so the user can allow/block this functionality)

@pandyama
Copy link
Author

@steimelchrome thanks, is there any sample code available anywhere to reference it & see how it works

@steimelchrome
Copy link
Collaborator

If you right-click on the page I linked above (https://steimelchrome.github.io/autopip.html) and click "View Page Source" it should show the underlying code. Most importantly, registering for the media session action handler like this:

navigator.mediaSession.setActionHandler('enterpictureinpicture', enterPip);

@pandyama
Copy link
Author

Gotcha, I just assumed page source may not have it, but it is raw html so makes sense... thanks!

@pandyama
Copy link
Author

@steimelchrome currently i see this error msg when I open the github.io page, I am guessing that's because my Chrome version is 117, and as you mentioned this is available in 120

TypeError: Failed to execute 'setActionHandler' on 'MediaSession': The provided value 'enterpictureinpicture' is not a valid enum value of type MediaSessionAction

@steimelchrome
Copy link
Collaborator

Yep, you'll need an updated Chrome Canary (which will be version 120) and then you can enable the flag at chrome://flags/#media-session-enter-picture-in-picture. Without that flag, you'll see that error message

@pandyama
Copy link
Author

sweet, thanks!

@tomayac
Copy link
Contributor

tomayac commented Oct 13, 2023

TypeError: Failed to execute 'setActionHandler' on 'MediaSession': The provided value 'enterpictureinpicture' is not a valid enum value of type MediaSessionAction

(See w3c/mediasession#228 where detecting supported action handlers is being discussed.)

@pandyama
Copy link
Author

thanks @tomayac will take a look at that

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

No branches or pull requests

3 participants