@@ -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