@@ -145,8 +145,10 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
145
145
const track = tracks . find ( ( track ) => track . active ) ;
146
146
if ( ! track ) {
147
147
if ( this . overflowQualityMark ) {
148
- this . overflowQualityMark . textContent = '' ;
149
- this . overflowQualityMark . style . display = 'none' ;
148
+ const stats = this . player . getStats ( ) ;
149
+ const mark = this . getQualityMark_ ( stats . width , stats . height ) ;
150
+ this . overflowQualityMark . textContent = mark ;
151
+ this . overflowQualityMark . style . display = mark !== '' ? '' : 'none' ;
150
152
}
151
153
return ;
152
154
}
@@ -165,7 +167,7 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
165
167
}
166
168
167
169
/** @type {string } */
168
- const mark = this . getQualityMark_ ( track ) ;
170
+ const mark = this . getQualityMark_ ( track . width , track . height ) ;
169
171
this . qualityMark . textContent = mark ;
170
172
this . qualityMark . style . display = mark !== '' ? '' : 'none' ;
171
173
if ( this . overflowQualityMark ) {
@@ -175,34 +177,37 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
175
177
}
176
178
177
179
/**
178
- * @param {!shaka.extern.VideoTrack } track
180
+ * @param {?number } width
181
+ * @param {?number } height
179
182
* @return {string }
180
183
* @private
181
184
*/
182
- getQualityMark_ ( track ) {
183
- let trackHeight = track . height || 0 ;
184
- let trackWidth = track . width || 0 ;
185
+ getQualityMark_ ( width , height ) {
186
+ if ( ! width || ! height ) {
187
+ return '' ;
188
+ }
189
+ let trackHeight = height ;
190
+ let trackWidth = width ;
185
191
if ( trackHeight > trackWidth ) {
186
192
// Vertical video.
187
193
[ trackWidth , trackHeight ] = [ trackHeight , trackWidth ] ;
188
194
}
189
- let height = trackHeight ;
190
195
const aspectRatio = trackWidth / trackHeight ;
191
196
if ( aspectRatio > ( 16 / 9 ) ) {
192
- height = Math . round ( trackWidth * 9 / 16 ) ;
197
+ trackHeight = Math . round ( trackWidth * 9 / 16 ) ;
193
198
}
194
199
const qualityMarks = this . controls . getConfig ( ) . qualityMarks ;
195
- if ( height >= 8640 ) {
196
- return height + 'p' ;
197
- } else if ( height >= 4320 ) {
200
+ if ( trackHeight >= 8640 ) {
201
+ return trackHeight + 'p' ;
202
+ } else if ( trackHeight >= 4320 ) {
198
203
return qualityMarks [ '4320' ] ;
199
- } else if ( height >= 2160 ) {
204
+ } else if ( trackHeight >= 2160 ) {
200
205
return qualityMarks [ '2160' ] ;
201
- } else if ( height >= 1440 ) {
206
+ } else if ( trackHeight >= 1440 ) {
202
207
return qualityMarks [ '1440' ] ;
203
- } else if ( height >= 1080 ) {
208
+ } else if ( trackHeight >= 1080 ) {
204
209
return qualityMarks [ '1080' ] ;
205
- } else if ( height >= 720 ) {
210
+ } else if ( trackHeight >= 720 ) {
206
211
return qualityMarks [ '720' ] ;
207
212
}
208
213
return '' ;
@@ -409,7 +414,7 @@ shaka.ui.ResolutionSelection = class extends shaka.ui.SettingsMenu {
409
414
}
410
415
button . appendChild ( span ) ;
411
416
412
- const mark = this . getQualityMark_ ( track ) ;
417
+ const mark = this . getQualityMark_ ( track . width , track . height ) ;
413
418
if ( mark !== '' ) {
414
419
const markEl = shaka . util . Dom . createHTMLElement ( 'sup' ) ;
415
420
markEl . classList . add ( 'shaka-quality-mark' ) ;
0 commit comments