mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1829697 - fix Sonyliv subtitles display for PIP video player. r=pip-reviewers,kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D176798
This commit is contained in:
parent
35eab701e2
commit
fb445e036b
@ -195,7 +195,7 @@ let AVAILABLE_PIP_OVERRIDES;
|
||||
|
||||
sonyliv: {
|
||||
"https://*.sonyliv.com/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/videojsWrapper.js",
|
||||
videoWrapperScriptPath: "video-wrappers/sonyliv.js",
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -42,6 +42,7 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] +=
|
||||
"video-wrappers/piped.js",
|
||||
"video-wrappers/primeVideo.js",
|
||||
"video-wrappers/radiocanada.js",
|
||||
"video-wrappers/sonyliv.js",
|
||||
"video-wrappers/tubi.js",
|
||||
"video-wrappers/tubilive.js",
|
||||
"video-wrappers/twitch.js",
|
||||
|
@ -0,0 +1,39 @@
|
||||
/* 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(".player-ui-main-wrapper");
|
||||
|
||||
if (container) {
|
||||
updateCaptionsFunction("");
|
||||
const callback = function(mutationsList, observer) {
|
||||
let text = container.querySelector(
|
||||
`.text-track-wrapper:not([style*="display: none"])`
|
||||
)?.innerText;
|
||||
if (!text) {
|
||||
updateCaptionsFunction("");
|
||||
return;
|
||||
}
|
||||
|
||||
updateCaptionsFunction(text);
|
||||
};
|
||||
|
||||
// immediately invoke the callback function to add subtitles to the PiP window
|
||||
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