@@ -198,12 +198,30 @@ export const getActiveMediaAtom = (
198198 videoReplace : boolean ,
199199 mediaAtom ?: FEMediaAtom ,
200200 cardTrailImage ?: string ,
201+ isLoopVideoLoadTest ?: boolean ,
201202) : MainMedia | undefined => {
202203 if ( mediaAtom ) {
203- const assets = mediaAtom . assets
204- . filter ( ( _ ) => _ . assetType === 'Video' )
205- . filter ( ( { version } ) => version === mediaAtom . activeVersion ) ;
206- if ( ! assets . length ) return undefined ;
204+ let assets ;
205+ if ( isLoopVideoLoadTest ) {
206+ /* temporarily filter out m3u8 files */
207+ assets = mediaAtom . assets
208+ . filter ( ( _ ) => ! m3u8MimeType . includes ( _ . mimeType ?? '' ) )
209+ . filter ( ( { version } ) => version === mediaAtom . activeVersion ) ;
210+ } else {
211+ assets = mediaAtom . assets . filter (
212+ ( { version } ) => version === mediaAtom . activeVersion ,
213+ ) ;
214+ }
215+
216+ const m3u8MimeType = [
217+ 'application/vnd.apple.mpegurl' ,
218+ 'application/x-mpegURL' ,
219+ ] ;
220+
221+ const videoAssets = assets . filter (
222+ ( { assetType } ) => assetType === 'Video' ,
223+ ) ;
224+ if ( ! videoAssets . length ) return undefined ;
207225
208226 const image = decideMediaAtomImage (
209227 videoReplace ,
@@ -279,11 +297,17 @@ const decideMedia = (
279297 imageHide ?: boolean ,
280298 videoReplace ?: boolean ,
281299 cardImage ?: string ,
300+ isLoopVideoLoadTest ?: boolean ,
282301) : MainMedia | undefined => {
283302 // If the showVideo toggle is enabled in the fronts tool,
284303 // we should return the active mediaAtom regardless of the design
285304 if ( ! ! showMainVideo || ! ! videoReplace ) {
286- return getActiveMediaAtom ( ! ! videoReplace , mediaAtom , cardImage ) ;
305+ return getActiveMediaAtom (
306+ ! ! videoReplace ,
307+ mediaAtom ,
308+ cardImage ,
309+ isLoopVideoLoadTest ,
310+ ) ;
287311 }
288312
289313 switch ( format . design ) {
@@ -298,7 +322,12 @@ const decideMedia = (
298322 } ;
299323
300324 case ArticleDesign . Video : {
301- return getActiveMediaAtom ( false , mediaAtom , cardImage ) ;
325+ return getActiveMediaAtom (
326+ false ,
327+ mediaAtom ,
328+ cardImage ,
329+ isLoopVideoLoadTest ,
330+ ) ;
302331 }
303332
304333 default :
@@ -315,6 +344,7 @@ export const enhanceCards = (
315344 pageId,
316345 discussionApiUrl,
317346 stripBranding = false ,
347+ isLoopVideoLoadTest,
318348 } : {
319349 cardInTagPage : boolean ;
320350 /** Used for the data link name to indicate card position in container */
@@ -324,6 +354,7 @@ export const enhanceCards = (
324354 discussionApiUrl : string ;
325355 /** We strip branding from cards if the branding will appear at the collection level instead */
326356 stripBranding ?: boolean ;
357+ isLoopVideoLoadTest ?: boolean ;
327358 } ,
328359) : DCRFrontCard [ ] =>
329360 collections . map ( ( faciaCard , index ) => {
@@ -379,6 +410,7 @@ export const enhanceCards = (
379410 faciaCard . display . imageHide ,
380411 faciaCard . properties . mediaSelect ?. videoReplace ,
381412 imageSrc ,
413+ isLoopVideoLoadTest ,
382414 ) ;
383415
384416 return {
0 commit comments