@@ -130,17 +130,29 @@ shaka.ads.Utils = class {
130
130
*/
131
131
static processNonLinearAd_ ( interstitials , currentTime , nonLinear ) {
132
132
const TXml = shaka . util . TXml ;
133
- const staticResource = TXml . findChild ( nonLinear , 'StaticResource' ) ;
134
- if ( ! staticResource ) {
135
- return ;
133
+ let mimeType = null ;
134
+ let resource = TXml . findChild ( nonLinear , 'StaticResource' ) ;
135
+ if ( resource ) {
136
+ mimeType = resource . attributes [ 'creativeType' ] ;
137
+ } else {
138
+ resource = TXml . findChild ( nonLinear , 'HTMLResource' ) ;
139
+ if ( ! resource ) {
140
+ return ;
141
+ }
142
+ mimeType = 'text/html' ;
136
143
}
137
- const adUrl = TXml . getContents ( staticResource ) ;
144
+ let adUrl = TXml . getContents ( resource ) ;
138
145
if ( ! adUrl ) {
139
146
return ;
140
147
}
141
- const width = TXml . parseAttr ( nonLinear , 'width' , TXml . parseInt ) ;
142
- const height = TXml . parseAttr ( nonLinear , 'height' , TXml . parseInt ) ;
143
- if ( ! width || ! height ) {
148
+ if ( mimeType === 'text/html' ) {
149
+ adUrl = 'data:text/html;charset=UTF-8,' + encodeURIComponent ( adUrl ) ;
150
+ }
151
+ const width = TXml . parseAttr ( nonLinear , 'width' , TXml . parseInt ) ||
152
+ TXml . parseAttr ( nonLinear , 'expandedWidth' , TXml . parseInt ) ;
153
+ const height = TXml . parseAttr ( nonLinear , 'height' , TXml . parseInt ) ||
154
+ TXml . parseAttr ( nonLinear , 'expandedHeight' , TXml . parseInt ) ;
155
+ if ( ! width && ! height ) {
144
156
return ;
145
157
}
146
158
let playoutLimit = null ;
@@ -158,7 +170,7 @@ shaka.ads.Utils = class {
158
170
startTime : startTime ,
159
171
endTime : null ,
160
172
uri : adUrl ,
161
- mimeType : staticResource . attributes [ 'creativeType' ] || null ,
173
+ mimeType,
162
174
isSkippable : false ,
163
175
skipOffset : null ,
164
176
skipFor : null ,
@@ -180,8 +192,8 @@ shaka.ads.Utils = class {
180
192
y : 0 ,
181
193
} ,
182
194
size : {
183
- x : width ,
184
- y : height ,
195
+ x : width || 0 ,
196
+ y : height || 0 ,
185
197
} ,
186
198
} ,
187
199
} ) ;
0 commit comments