Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit be84df2

Browse files
MortimerGorobluemarvin
authored andcommitted
Fix Youtube 360 stereo video layout issues (#2634)
1 parent 174d5bd commit be84df2

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

app/src/main/assets/web_extensions/webcompat_youtube/main.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,13 @@ ytd-rich-grid-video-renderer {
3636
--ytd-rich-grid-posts-per-row: 4 !important;
3737
}
3838
}
39+
40+
41+
/* Youtube Videos tagged with Stereo VR have a layout problem, they don't take the whole area
42+
of the video. This styles are used to make sure the video has the correct size for immersive
43+
playback */
44+
div.ytp-fullscreen video, .fxr-vr-video {
45+
width: 100% !important;
46+
left: 0px !important;
47+
}
48+

app/src/main/assets/web_extensions/webcompat_youtube/main.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class YoutubeExtension {
7878
const qs = new URLSearchParams(window.location.search);
7979
if (qs.get(VIDEO_PROJECTION_PARAM)) {
8080
logDebug(`Video has already a video projection selected: ${qs.get(VIDEO_PROJECTION_PARAM)}`);
81+
this.updateVideoStyle();
8182
return;
8283
}
8384
// There is no standard API to detect video projection yet.
@@ -90,12 +91,21 @@ class YoutubeExtension {
9091
if (is360) {
9192
qs.set('mozVideoProjection', '360_auto');
9293
this.updateURL(qs);
94+
this.updateVideoStyle();
9395
logDebug(`Video projection set to: ${qs.get(VIDEO_PROJECTION_PARAM)}`);
9496
} else {
9597
logDebug(`Video is flat, no projection selected`);
9698
}
9799
}
98100

101+
updateVideoStyle() {
102+
const video = this.getVideo();
103+
if (video) {
104+
video.classList.add('fxr-vr-video');
105+
logDebug('Added video projection style');
106+
}
107+
}
108+
99109
overrideClick(event) {
100110
this.overrideVideoProjection();
101111
const player = this.getPlayer();
@@ -117,15 +127,15 @@ class YoutubeExtension {
117127
// Force video play when entering immersive mode.
118128
setTimeout(() => this.retry("PlayVideo", () => {
119129
player.playVideo();
120-
return !document.getElementsByTagName("video")[0].paused;
130+
return !this.getVideo().paused;
121131
}), 200);
122132
}
123133
}
124134

125135
// Runs the callback when the video is ready (has loaded the first frame).
126136
waitForVideoReady(callback) {
127137
this.retry("VideoReady", () => {
128-
const video = document.getElementsByTagName("video")[0];
138+
const video = this.getVideo();
129139
if (!video) {
130140
return false;
131141
}
@@ -147,6 +157,10 @@ class YoutubeExtension {
147157
return player.wrappedJSObject;
148158
}
149159

160+
getVideo() {
161+
return document.getElementsByTagName('video')[0];
162+
}
163+
150164
// Get's the preferred video qualities for the current device.
151165
getPreferredQualities() {
152166
let all = ['hd2880', 'hd2160','hd1440', 'hd1080', 'hd720', 'large', 'medium'];
@@ -169,7 +183,7 @@ class YoutubeExtension {
169183
}
170184

171185
isVideoReady() {
172-
const video = document.getElementsByTagName("video")[0];
186+
const video = this.getVideo();
173187
return video && video.readyState >=2;
174188
}
175189

0 commit comments

Comments
 (0)