Allow Picture-in-Picture player window to continue playing if originating tab closes
Categories
(Toolkit :: Picture-in-Picture, enhancement, P3)
Tracking
()
People
(Reporter: mconley, Unassigned, NeedInfo)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file)
I'm not sure how possible this is, but it's something that was discussed in Whistler as a way of differentiating our Picture-in-Picture implementation.
Reporter | ||
Comment 1•5 years ago
|
||
We'd need a way of keeping the original <video> element (or, at least, it's stream of data and decoder) alive after the originating tab / window closes.
Reporter | ||
Updated•5 years ago
|
Reporter | ||
Comment 2•5 years ago
|
||
One way of doing this is by hiding any tab with a PiP player window open instead of closing it.
Reporter | ||
Comment 4•4 years ago
|
||
I just thought up an approach to this, and I wanted to get it down before I forget:
When closing a tab that's using PiP, we could create a new <browser> inside of the player window, and swap frameloaders with the original tab, and then close the original tab. This would be effectively like dragging the originating tab into an invisible space within the player window. This would keep the DOM content alive, and would keep the video running. The document would remain alive until the player window is closed.
There would have to be some kind of consideration about what to do in the event that the site tried to do something that would normally cause some UI to be presented to the user (for example, requesting geolocation access). I imagine, however, that we might be able to treat the hidden browser like we treat the thumbnail browser, and deny all permissions after it goes into this state.
Comment 5•4 years ago
|
||
(In reply to Mike Conley (:mconley) (:⚙️) from comment #4)
I really like this idea. If the permission thing becomes a problem, we can add a button to swap the browser back into a real window and show the permission prompt upon the completed swap.
Reporter | ||
Updated•3 years ago
|
Comment 7•3 years ago
|
||
Updated•3 years ago
|
Comment 8•3 years ago
|
||
(In reply to Mike Conley (:mconley) (:⚙️) (Catching up on needinfos) from comment #4)
When closing a tab that's using PiP, we could create a new <browser> inside of the player window, and swap frameloaders with the original tab, and then close the original tab.
Hey Mike, Oliver and I have tried experimenting with this recently. For myself, I've attempted doing what PaymentUIService._moveDialogToNewBrowser does for swapping frameloaders but adjusted for PiP:
When "TabClose" event occurs on the original tab:
saveTab(event) {
let browser = event.target.linkedBrowser;
for (let win of Services.wm.getEnumerator(WINDOW_TYPE)) {
// Get the associated PiP window of the closing tab
if (this.weakWinToBrowser.get(win) === browser) {
// Create a new <browser> to preserve the DOM content
let frame = win.document.createXULElement("browser");
frame.setAttribute("type", "content");
frame.setAttribute("remote", "true");
// Set append the new <browser> element to the PiP player document (will need some styling)
let container = win.document.getElementById("saved-tabs-container");
container.appendChild(frame);
// Swap frameloaders between the original tab's browser to the new one
frame.swapFrameLoaders(browser);
}
}
},
But at swapFrameLoaders
I get NS_ERROR_NOT_IMPLEMENTED:
thrown in the browser console. I'm wondering if you might have any ideas about what I might be doing wrong here (and what the error means here).
Reporter | ||
Updated•3 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Description
•