mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-24 09:27:31 +09:00
more PiP fixes
This commit is contained in:
parent
2ebf29a6aa
commit
aac2156499
6 changed files with 56 additions and 7 deletions
7
browser/base/content/pictureInPicture.css
Normal file
7
browser/base/content/pictureInPicture.css
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
browser[remote="true"] {
|
||||||
|
-moz-binding: url("chrome://global/content/bindings/remote-browser.xml#remote-browser");
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,9 @@ var Player = {
|
||||||
sourceTab: null,
|
sourceTab: null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
if (this.browser) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let args = window.arguments[0];
|
let args = window.arguments[0];
|
||||||
this.source = args.browser;
|
this.source = args.browser;
|
||||||
if (!this.source || !this.source.isConnected) {
|
if (!this.source || !this.source.isConnected) {
|
||||||
|
|
@ -38,9 +41,16 @@ var Player = {
|
||||||
browser.relatedBrowser = this.source;
|
browser.relatedBrowser = this.source;
|
||||||
document.getElementById("player-container").appendChild(browser);
|
document.getElementById("player-container").appendChild(browser);
|
||||||
let mm = browser.messageManager;
|
let mm = browser.messageManager;
|
||||||
mm.addMessageListener("PictureInPicture:Ready", () => {
|
let initialized = false;
|
||||||
|
let ready = () => {
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
|
mm.removeMessageListener("PictureInPicture:Ready", ready);
|
||||||
mm.sendAsyncMessage("PictureInPicture:Init", {id: args.id});
|
mm.sendAsyncMessage("PictureInPicture:Init", {id: args.id});
|
||||||
});
|
};
|
||||||
|
mm.addMessageListener("PictureInPicture:Ready", ready);
|
||||||
mm.addMessageListener("PictureInPicture:Close", this.close);
|
mm.addMessageListener("PictureInPicture:Close", this.close);
|
||||||
mm.addMessageListener("PictureInPicture:State", message => {
|
mm.addMessageListener("PictureInPicture:State", message => {
|
||||||
document.getElementById("play").label = message.data.paused ?
|
document.getElementById("play").label = message.data.paused ?
|
||||||
|
|
@ -79,8 +89,20 @@ var Player = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("load", () => Player.init(), {once: true});
|
// Only consume the listener for the player document's own load, rather than
|
||||||
window.addEventListener("unload", () => Player.destroy(), {once: true});
|
// a load from the embedded browser.
|
||||||
|
window.addEventListener("load", function onLoad(event) {
|
||||||
|
if (event.target == document) {
|
||||||
|
window.removeEventListener("load", onLoad);
|
||||||
|
Player.init();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.addEventListener("unload", function onUnload(event) {
|
||||||
|
if (event.target == document) {
|
||||||
|
window.removeEventListener("unload", onUnload);
|
||||||
|
Player.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
window.addEventListener("keydown", event => {
|
window.addEventListener("keydown", event => {
|
||||||
if (event.key == "Escape") {
|
if (event.key == "Escape") {
|
||||||
window.close();
|
window.close();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||||
|
<?xml-stylesheet href="chrome://browser/content/pictureInPicture.css" type="text/css"?>
|
||||||
<!DOCTYPE window SYSTEM "chrome://browser/locale/browser.dtd">
|
<!DOCTYPE window SYSTEM "chrome://browser/locale/browser.dtd">
|
||||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
id="picture-in-picture" windowtype="Browser:PictureInPicture"
|
id="picture-in-picture" windowtype="Browser:PictureInPicture"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ var output = null;
|
||||||
var still = null;
|
var still = null;
|
||||||
var observer = null;
|
var observer = null;
|
||||||
var sourceWindow = null;
|
var sourceWindow = null;
|
||||||
|
var initialized = false;
|
||||||
var events = ["play", "pause", "volumechange", "ended", "seeked", "resize"];
|
var events = ["play", "pause", "volumechange", "ended", "seeked", "resize"];
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
|
@ -63,6 +64,12 @@ function closePlayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
addMessageListener("PictureInPicture:Init", message => {
|
addMessageListener("PictureInPicture:Init", message => {
|
||||||
|
// takeSource consumes the handoff. A duplicate initialization must not
|
||||||
|
// consume it again or close an already playing window.
|
||||||
|
if (initialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initialized = true;
|
||||||
try {
|
try {
|
||||||
source = PictureInPicture.takeSource(message.data.id);
|
source = PictureInPicture.takeSource(message.data.id);
|
||||||
sourceWindow = source.ownerGlobal;
|
sourceWindow = source.ownerGlobal;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
browser.jar:
|
browser.jar:
|
||||||
content/browser/pictureInPicture.xul (content/pictureInPicture.xul)
|
content/browser/pictureInPicture.xul (content/pictureInPicture.xul)
|
||||||
content/browser/pictureInPicture.js (content/pictureInPicture.js)
|
content/browser/pictureInPicture.js (content/pictureInPicture.js)
|
||||||
|
content/browser/pictureInPicture.css (content/pictureInPicture.css)
|
||||||
content/browser/pictureInPictureContent.js (content/pictureInPictureContent.js)
|
content/browser/pictureInPictureContent.js (content/pictureInPictureContent.js)
|
||||||
% content browser %content/browser/ contentaccessible=yes
|
% content browser %content/browser/ contentaccessible=yes
|
||||||
#ifdef XP_MACOSX
|
#ifdef XP_MACOSX
|
||||||
|
|
|
||||||
|
|
@ -881,9 +881,20 @@ ContentParent::CreateBrowser(const TabContext& aContext,
|
||||||
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
|
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
|
||||||
openerTabId, &tabId);
|
openerTabId, &tabId);
|
||||||
} else {
|
} else {
|
||||||
constructorSender =
|
if (aOpenerContentParent && !aFreshProcess) {
|
||||||
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
|
// relatedBrowser requires the same process, not another process from
|
||||||
initialPriority, nullptr, aFreshProcess);
|
// the pool. Picture-in-Picture shares a video through a process-local
|
||||||
|
// module, and cannot use a randomly selected content process.
|
||||||
|
if (!aOpenerContentParent->IsAlive() ||
|
||||||
|
aOpenerContentParent->IsForBrowser() != aContext.IsMozBrowserElement()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
constructorSender = aOpenerContentParent;
|
||||||
|
} else {
|
||||||
|
constructorSender =
|
||||||
|
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
|
||||||
|
initialPriority, nullptr, aFreshProcess);
|
||||||
|
}
|
||||||
if (!constructorSender) {
|
if (!constructorSender) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue