Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Add Background Playback and PIP for WebPages #4031

Closed
Brandon-T opened this issue Aug 12, 2021 · 3 comments · Fixed by #4032
Closed

Add Background Playback and PIP for WebPages #4031

Brandon-T opened this issue Aug 12, 2021 · 3 comments · Fixed by #4032

Comments

@Brandon-T
Copy link
Collaborator

Feature Overview

  • Websites like youtube do not support Background play or Picture-In-Picture.
  • Want to be able to play videos (background audio) on lock screen and picture in picture when on the home-screen.

Implementation Details

  • Picture-In-Picture needs the webkitpresentationmodechanged event blocked from propagating/bubbling.
  • Background-Mode is trickier as Webkit itself calls pause on the HTMLMediaElement so you need to resume playback. However, websites like youtube also break playback even if it were fixed in youtube, by listening to the visibilitychange event and pausing the HTMLMediaElement.

User Experience

  1. Play a video on a website
  2. Background the browser
  3. Should still play.
  4. Lock the device.
  5. Should still play.
  6. Pause and then play again on the lock-screen; should work.
@gh0sti
Copy link

gh0sti commented Aug 12, 2021

Brave already can do PiP for youtube if you are a youtube premium subscriber in the browser since Brave is built on Webkit. Background play will be interesting, are there other browsers allowed to do this?

@Brandon-T
Copy link
Collaborator Author

Brandon-T commented Aug 12, 2021

Brave already can do PiP for youtube if you are a youtube premium subscriber in the browser since Brave is built on Webkit. Background play will be interesting, are there other browsers allowed to do this?

Hi :)

I am aware of the Youtube Premium subscription. Same for a few other websites and apps that block OS functionality behind a subscription service.

Youtube (and others) is not supposed to charge for features such as PIP or Background play as these are native to the OS (not sure why Apple allows them to do it). This is in direct contradiction to (as far as I can tell):

3.2.2 Unacceptable
(ii) Monetizing built-in capabilities provided by the hardware or operating system, such as Push Notifications, the camera, or the gyroscope; or Apple services, such as Apple Music access or iCloud storage.

from: https://developer.apple.com/app-store/review/guidelines/

Picture in Picture and Background modes work on all other websites by default, as it is a WebKit feature (you are correct) and OS level feature (iOS 13+ or 14+ for PIP). However, websites like youtube explicitly disable it on purpose and puts it behind Youtube Premium or whichever website subscription.

This ticket and the Pull-Request associated with it, is to fix it -- to allow it to work on ALL sites with or without paying for "premium".

Currently, there are no other third-party browsers that allow background play or PIP as far as I am aware (correct me if I'm wrong :) ). I know that Safari iOS does support Background Play and WebRTC background streaming on iOS 14.5+, but this is not available to third-party browsers yet (specifically the WebRTC background streaming).

@srirambv
Copy link
Contributor

Verification passed on iPad Pro with iOS 15 running 1.31(21.9.14.15)

  • Verified able to play a video on a website
  • Verified able to continue playback audio in background when browser is in background
  • Verified able to continue playback audio when device is locked
  • Verified able to add video to playlist and still able to play in PiP mode when browser is put in background
  • Verified able to continue playback on PiP from playlist when device locked

Verification passed on iPhone 7+ with iOS 14.8 running 1.31(21.9.14.15)

  • Verified able to play a video on a website
  • Verified able to continue playback audio in background when browser is in background
  • Verified able to continue playback audio when device is locked
  • Verified able to add video to playlist and still able to play in PiP mode when browser is put in background
  • Verified able to continue playback on PiP from playlist when device locked

Verification passed on iPhone XR with iOS 13.5 running 1.31(21.9.14.15)

  • Verified able to play a video on a website
  • Verified able to continue playback audio in background when browser is in background
  • Verified able to continue playback audio when device is locked

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.