@@ -107,7 +107,8 @@ shaka.abr.SimpleAbrManager = class {
107
107
108
108
/** @private {shaka.util.Timer} */
109
109
this . resizeObserverTimer_ = new shaka . util . Timer ( ( ) => {
110
- if ( this . enabled_ && this . config_ . restrictToElementSize ) {
110
+ if ( this . enabled_ && ( this . config_ . restrictToElementSize ||
111
+ this . config_ . restrictToScreenSize ) ) {
111
112
const chosenVariant = this . chooseVariant ( ) ;
112
113
if ( chosenVariant ) {
113
114
this . switch_ ( chosenVariant , this . config_ . clearBufferSwitch ,
@@ -116,6 +117,26 @@ shaka.abr.SimpleAbrManager = class {
116
117
}
117
118
} ) ;
118
119
120
+ /** @private {Window} */
121
+ this . windowToCheck_ = window ;
122
+
123
+ if ( 'documentPictureInPicture' in window ) {
124
+ this . eventManager_ . listen (
125
+ window . documentPictureInPicture , 'enter' , ( ) => {
126
+ this . windowToCheck_ = window . documentPictureInPicture . window ;
127
+ if ( this . resizeObserverTimer_ ) {
128
+ this . resizeObserverTimer_ . tickNow ( ) ;
129
+ }
130
+ this . eventManager_ . listenOnce (
131
+ this . windowToCheck_ , 'pagehide' , ( ) => {
132
+ this . windowToCheck_ = window ;
133
+ if ( this . resizeObserverTimer_ ) {
134
+ this . resizeObserverTimer_ . tickNow ( ) ;
135
+ }
136
+ } ) ;
137
+ } ) ;
138
+ }
139
+
119
140
/** @private {?shaka.util.CmsdManager} */
120
141
this . cmsdManager_ = null ;
121
142
}
@@ -176,15 +197,15 @@ shaka.abr.SimpleAbrManager = class {
176
197
let maxWidth = Infinity ;
177
198
178
199
if ( this . config_ . restrictToScreenSize ) {
179
- const devicePixelRatio =
180
- this . config_ . ignoreDevicePixelRatio ? 1 : window . devicePixelRatio ;
181
- maxHeight = window . screen . height * devicePixelRatio ;
182
- maxWidth = window . screen . width * devicePixelRatio ;
200
+ const devicePixelRatio = this . config_ . ignoreDevicePixelRatio ?
201
+ 1 : this . windowToCheck_ . devicePixelRatio ;
202
+ maxHeight = this . windowToCheck_ . screen . height * devicePixelRatio ;
203
+ maxWidth = this . windowToCheck_ . screen . width * devicePixelRatio ;
183
204
}
184
205
185
206
if ( this . resizeObserver_ && this . config_ . restrictToElementSize ) {
186
- const devicePixelRatio =
187
- this . config_ . ignoreDevicePixelRatio ? 1 : window . devicePixelRatio ;
207
+ const devicePixelRatio = this . config_ . ignoreDevicePixelRatio ?
208
+ 1 : this . windowToCheck_ . devicePixelRatio ;
188
209
maxHeight = Math . min (
189
210
maxHeight , this . mediaElement_ . clientHeight * devicePixelRatio ) ;
190
211
maxWidth = Math . min (
0 commit comments