Skip to content

Commit 7ff2f9d

Browse files
authored
Merge pull request #14414 from guardian/fp/filter-out-m3u8
Filter out m3u8 assets until supported by DCR
2 parents 1ee6d5c + 6b9566d commit 7ff2f9d

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

dotcom-rendering/src/frontend/feFront.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export type FEFrontCardStyle =
106106
| 'DefaultCardstyle';
107107

108108
/** @see https://github.com/guardian/frontend/blob/0bf69f55a/common/app/model/content/Atom.scala#L191-L196 */
109-
interface FEMediaAsset {
109+
export interface FEMediaAsset {
110110
id: string;
111111
version: number;
112112
platform: string;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import type { FEMediaAsset, FEMediaAtom } from '../frontend/feFront';
2+
import { getActiveMediaAtom } from './enhanceCards';
3+
4+
describe('Enhance Cards', () => {
5+
it('filters out m3u8 assets until supported by DCR', () => {
6+
const isLoopingVideoTest = true;
7+
const videoReplace = true;
8+
const assets: FEMediaAsset[] = [
9+
{
10+
id: 'https://guim-example.co.uk/atomID-1.m3u8',
11+
version: 1,
12+
platform: 'Url',
13+
mimeType: 'application/vnd.apple.mpegurl',
14+
},
15+
{
16+
id: 'https://guim-example.co.uk/atomID-1.mp4',
17+
version: 1,
18+
platform: 'Url',
19+
mimeType: 'video/mp4',
20+
},
21+
];
22+
const mediaAtom: FEMediaAtom = {
23+
id: 'atomID',
24+
assets,
25+
title: 'Example video',
26+
duration: 15,
27+
source: '',
28+
posterImage: { allImages: [] },
29+
trailImage: { allImages: [] },
30+
expired: false,
31+
activeVersion: 1,
32+
};
33+
const cardTrailImage = '';
34+
35+
expect(
36+
getActiveMediaAtom(
37+
isLoopingVideoTest,
38+
videoReplace,
39+
mediaAtom,
40+
cardTrailImage,
41+
),
42+
).toEqual({
43+
atomId: 'atomID',
44+
duration: 15,
45+
height: 400,
46+
image: '',
47+
type: 'LoopVideo',
48+
videoId: 'https://guim-example.co.uk/atomID-1.mp4',
49+
width: 500,
50+
});
51+
});
52+
});

dotcom-rendering/src/model/enhanceCards.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,18 @@ const decideMediaAtomImage = (
192192
* @see https://github.com/guardian/frontend/pull/26247 for inspiration
193193
*/
194194

195-
const getActiveMediaAtom = (
195+
export const getActiveMediaAtom = (
196196
isLoopingVideoTest: boolean,
197197
videoReplace: boolean,
198198
mediaAtom?: FEMediaAtom,
199199
cardTrailImage?: string,
200200
): MainMedia | undefined => {
201201
if (mediaAtom) {
202-
const asset = mediaAtom.assets.find(
203-
({ version }) => version === mediaAtom.activeVersion,
204-
);
202+
const m3u8MimeType = 'application/vnd.apple.mpegurl';
203+
const asset = mediaAtom.assets
204+
// filter out m3u8 assets, as these are not yet supported by DCR
205+
.filter((_) => _.mimeType !== m3u8MimeType)
206+
.find(({ version }) => version === mediaAtom.activeVersion);
205207

206208
const image = decideMediaAtomImage(
207209
videoReplace,

0 commit comments

Comments
 (0)