зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1766388 - Add Video-Adapter for supporting Hotstar Subtitles. r=kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D144786
This commit is contained in:
Родитель
0e2c94648d
Коммит
ceb716d8ff
|
@ -51,6 +51,12 @@ let AVAILABLE_PIP_OVERRIDES;
|
|||
},
|
||||
},
|
||||
|
||||
hotstar: {
|
||||
"https://*.hotstar.com/*": {
|
||||
videoWrapperScriptPath: "video-wrappers/hotstar.js",
|
||||
},
|
||||
},
|
||||
|
||||
instagram: {
|
||||
"https://www.instagram.com/*": { policy: TOGGLE_POLICIES.ONE_QUARTER },
|
||||
},
|
||||
|
|
|
@ -30,6 +30,7 @@ FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["lib"] += [
|
|||
FINAL_TARGET_FILES.features["pictureinpicture@mozilla.org"]["video-wrappers"] += [
|
||||
"video-wrappers/airmozilla.js",
|
||||
"video-wrappers/funimation.js",
|
||||
"video-wrappers/hotstar.js",
|
||||
"video-wrappers/mock-wrapper.js",
|
||||
"video-wrappers/netflix.js",
|
||||
"video-wrappers/piped.js",
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/* 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(".subtitle-container");
|
||||
|
||||
if (container) {
|
||||
updateCaptionsFunction("");
|
||||
const callback = function(mutationsList, observer) {
|
||||
let textNodeList = container
|
||||
.querySelector(".shaka-text-container")
|
||||
?.querySelectorAll("span");
|
||||
if (!textNodeList) {
|
||||
updateCaptionsFunction("");
|
||||
return;
|
||||
}
|
||||
|
||||
updateCaptionsFunction(
|
||||
Array.from(textNodeList, x => x.textContent).join("\n")
|
||||
);
|
||||
};
|
||||
|
||||
// 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;
|
|
@ -1366,6 +1366,8 @@ class PictureInPictureChild extends JSWindowActorChild {
|
|||
this.setActiveTextTrack(originatingVideo.textTracks);
|
||||
|
||||
if (!this._currentWebVTTTrack) {
|
||||
// If WebVTT track is invalid, try using a video wrapper
|
||||
this.setUpCaptionChangeListener(originatingVideo);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1787,7 +1789,7 @@ class PictureInPictureChild extends JSWindowActorChild {
|
|||
for (let i = 0; i < textTrackList.length; i++) {
|
||||
let track = textTrackList[i];
|
||||
let isCCText = track.kind === "subtitles" || track.kind === "captions";
|
||||
if (isCCText && track.mode === "showing") {
|
||||
if (isCCText && track.mode === "showing" && track.cues) {
|
||||
this._currentWebVTTTrack = track;
|
||||
break;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче