mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1831499 - PiP subtitle support for Arte. r=pip-reviewers,mhowell
Differential Revision: https://phabricator.services.mozilla.com/D181810
This commit is contained in:
parent
fb92d5f42f
commit
b686868bde
@ -61,6 +61,12 @@ let AVAILABLE_PIP_OVERRIDES;
|
||||
},
|
||||
},
|
||||
|
||||
arte: {
|
||||
"https://*.arte.tv/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/arte.js",
|
||||
},
|
||||
},
|
||||
|
||||
bbc: {
|
||||
"https://*.bbc.com/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/bbc.js",
|
||||
|
@ -29,6 +29,7 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["lib"] += [
|
||||
|
||||
FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] += [
|
||||
"video-wrappers/airmozilla.js",
|
||||
"video-wrappers/arte.js",
|
||||
"video-wrappers/bbc.js",
|
||||
"video-wrappers/cbc.js",
|
||||
"video-wrappers/dailymotion.js",
|
||||
|
35
browser/extensions/pictureinpicture/video-wrappers/arte.js
Normal file
35
browser/extensions/pictureinpicture/video-wrappers/arte.js
Normal file
@ -0,0 +1,35 @@
|
||||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
class PictureInPictureVideoWrapper {
|
||||
setCaptionContainerObserver(video, updateCaptionsFunction) {
|
||||
let container = document.querySelector(".avp-captions");
|
||||
|
||||
if (container) {
|
||||
updateCaptionsFunction("");
|
||||
const callback = function (mutationsList, observer) {
|
||||
let textNodeList = container.querySelectorAll(".avp-captions-line");
|
||||
if (!textNodeList.length) {
|
||||
updateCaptionsFunction("");
|
||||
return;
|
||||
}
|
||||
updateCaptionsFunction(
|
||||
Array.from(textNodeList, x => x.textContent).join("\n")
|
||||
);
|
||||
};
|
||||
callback([1], null);
|
||||
|
||||
let captionsObserver = new MutationObserver(callback);
|
||||
captionsObserver.observe(container, {
|
||||
attributes: false,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;
|
Loading…
Reference in New Issue
Block a user