Bug 1831499 - PiP subtitle support for Arte. r=pip-reviewers,mhowell

Differential Revision: https://phabricator.services.mozilla.com/D181810
This commit is contained in:
Tom Schuster 2023-07-05 21:28:50 +00:00
parent fb92d5f42f
commit b686868bde
3 changed files with 42 additions and 0 deletions

View File

@ -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",

View File

@ -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",

View 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;