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";
|
||||
|
||||
class PictureInPictureVideoWrapper {
|
||||
constructor(video) {
|
||||
this.player = video.closest("#movie_player")?.wrappedJSObject;
|
||||
}
|
||||
isLive(video) {
|
||||
return !!document.querySelector(".ytp-live");
|
||||
}
|
||||
setMuted(video, shouldMute) {
|
||||
let muteButton = document.querySelector("#player .ytp-mute-button");
|
||||
|
||||
if (video.muted !== shouldMute && muteButton) {
|
||||
muteButton.click();
|
||||
if (this.player) {
|
||||
if (shouldMute) {
|
||||
this.player.mute();
|
||||
} else {
|
||||
this.player.unMute();
|
||||
}
|
||||
} else {
|
||||
video.muted = shouldMute;
|
||||
}
|
||||
@ -60,6 +65,19 @@ class PictureInPictureVideoWrapper {
|
||||
shouldHideToggle(video) {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user