summaryrefslogtreecommitdiffstats
path: root/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js')
-rw-r--r--browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js b/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.js
new file mode 100644
index 0000000000..37591c16f8
--- /dev/null
+++ b/browser/extensions/pictureinpicture/video-wrappers/jwplayerWrapper.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";
+
+// This wrapper supports multiple sites that use JWPlayer
+class PictureInPictureVideoWrapper {
+ setCaptionContainerObserver(video, updateCaptionsFunction) {
+ let container = document.querySelector(".jw-captions");
+
+ if (container) {
+ updateCaptionsFunction("");
+
+ const callback = function () {
+ let text = container.innerText;
+ if (!text) {
+ updateCaptionsFunction("");
+ return;
+ }
+
+ updateCaptionsFunction(text);
+ };
+
+ // immediately invoke the callback function to add subtitles to the PiP window
+ callback();
+
+ let captionsObserver = new MutationObserver(callback);
+
+ captionsObserver.observe(container, {
+ attributes: false,
+ childList: true,
+ subtree: true,
+ });
+ }
+ }
+}
+
+this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;