daily-co / daily-js

https://docs.daily.co/reference/daily-js
BSD 2-Clause "Simplified" License
103 stars 33 forks source link

[FEATURE-REQUEST] picture-in-picture event #244

Open mklepaczewski opened 9 months ago

mklepaczewski commented 9 months ago

Feature request

Fire an event when the user enables picture-in-picture. Also, if possible, fire an event when the user disables it.

Why you need this

We want to apply different video settings when picture-in-picture is enabled.

markbackman commented 8 months ago

@mklepaczewski this is certainly possible. Before we add this, would you mind explaining the use case you have in mind?

mklepaczewski commented 8 months ago

@markbackman We want to apply lower video quality settings when user enables picture-in-picture. PiP usually uses a smaller window, which provides an opportunity to save bandwidth for users on data plan.

markbackman commented 8 months ago

Thanks for the info, @mklepaczewski. Is this for a custom app or Daily Prebuilt?

If it's Daily Prebuilt, the Prebuilt application is going to override any calls to updateReceiveSettings() as that's something that Prebuilt offers out of the box. Also, I wonder if this is a little more complex; the user has the ability to resize the PiP, so lowering the quality might not be the right choice. (Again, this is speaking about Daily Prebuilt.)

If this is for a custom app, there are browser level PiP APIs that I'd recommend using: https://developer.mozilla.org/en-US/docs/Web/API/Picture-in-Picture_API#events.

mklepaczewski commented 8 months ago

Thanks for the info, @mklepaczewski. Is this for a custom app or Daily Prebuilt?

Thank you for the update.

At the moment, we still use Daily Prebuilt. We use updateSendSettings() to control video quality (it works). Our use case is a bit specific. We can rely on users not to resize the PiP or accept that quality will be low if they decide to do so. Our users stay in a call for 8-10h/day, and we must apply custom quality settings to lower bandwidth and CPU usage.

markbackman commented 8 months ago

Since you're using P2P calls, are there always 2 people in a call? If so, you can listen to the enterpictureinpicture browser event, which will indicate when a PiP starts. Will that work for you?

mklepaczewski commented 8 months ago

@markbackman Yes, that will do, thank you.

Zupken commented 7 months ago

@markbackman I don't think it is possible to listen to enterpictureinpicture on iframe. I created a demo demonstrating this: https://codesandbox.io/p/devbox/pfyxlp I think that listening to enterpictureinpicture isn't solution to this problem.

markbackman commented 7 months ago

@markbackman I don't think it is possible to listen to enterpictureinpicture on iframe. I created a demo demonstrating this: https://codesandbox.io/p/devbox/pfyxlp I think that listening to enterpictureinpicture isn't solution to this problem.

Ahh, yes. The event doesn't bubble up to the parent frame. We can add this request to our backlog.

Zupken commented 7 months ago

Thank you, looking forward to this feature.

mklepaczewski commented 5 months ago

Reopening as our tests showed that the proposed solution by @markbackman indeed doesn't work due to the issue reported by @Zupken