Closed pandyama closed 1 year ago
"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)
@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
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?
@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
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)
Thanks @steimelchrome will keep an eye out for M120's release schedule!
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)
@steimelchrome thanks, is there any sample code available anywhere to reference it & see how it works
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);
Gotcha, I just assumed page source may not have it, but it is raw html so makes sense... thanks!
@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
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
sweet, thanks!
TypeError: Failed to execute 'setActionHandler' on 'MediaSession': The provided value 'enterpictureinpicture' is not a valid enum value of type MediaSessionAction
(See https://github.com/w3c/mediasession/issues/228 where detecting supported action handlers is being discussed.)
thanks @tomayac will take a look at that
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!