mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1580095 - Update youtube wrapper. r=pip-reviewers,mhowell
Depends on D179556 Differential Revision: https://phabricator.services.mozilla.com/D180873
This commit is contained in:
parent
de7d493744
commit
e7cb292746
@ -5,14 +5,19 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
class PictureInPictureVideoWrapper {
|
class PictureInPictureVideoWrapper {
|
||||||
|
constructor(video) {
|
||||||
|
this.player = video.closest("#movie_player")?.wrappedJSObject;
|
||||||
|
}
|
||||||
isLive(video) {
|
isLive(video) {
|
||||||
return !!document.querySelector(".ytp-live");
|
return !!document.querySelector(".ytp-live");
|
||||||
}
|
}
|
||||||
setMuted(video, shouldMute) {
|
setMuted(video, shouldMute) {
|
||||||
let muteButton = document.querySelector("#player .ytp-mute-button");
|
if (this.player) {
|
||||||
|
if (shouldMute) {
|
||||||
if (video.muted !== shouldMute && muteButton) {
|
this.player.mute();
|
||||||
muteButton.click();
|
} else {
|
||||||
|
this.player.unMute();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
video.muted = shouldMute;
|
video.muted = shouldMute;
|
||||||
}
|
}
|
||||||
@ -60,6 +65,19 @@ class PictureInPictureVideoWrapper {
|
|||||||
shouldHideToggle(video) {
|
shouldHideToggle(video) {
|
||||||
return !!video.closest(".ytd-video-preview");
|
return !!video.closest(".ytd-video-preview");
|
||||||
}
|
}
|
||||||
|
setVolume(video, volume) {
|
||||||
|
if (this.player) {
|
||||||
|
this.player.setVolume(volume * 100);
|
||||||
|
} else {
|
||||||
|
video.volume = volume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getVolume(video) {
|
||||||
|
if (this.player) {
|
||||||
|
return this.player.getVolume() / 100;
|
||||||
|
}
|
||||||
|
return video.volume;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;
|
this.PictureInPictureVideoWrapper = PictureInPictureVideoWrapper;
|
||||||
|
Loading…
Reference in New Issue
Block a user