Skip to content

Commit 51f6e4c

Browse files
✨ Add TargetVideo Alias To Brid AMP Player (#40151)
* Add TargetVideo Alias * Lint, address PR comments * Update validator, revert examples
1 parent 316898d commit 51f6e4c

File tree

3 files changed

+81
-4
lines changed

3 files changed

+81
-4
lines changed

extensions/amp-brid-player/0.1/amp-brid-player.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,7 @@ class AmpBridPlayer extends AMP.BaseElement {
493493
}
494494
}
495495

496-
AMP.extension(TAG, '0.1', (AMP) => {
497-
AMP.registerElement(TAG, AmpBridPlayer);
496+
AMP.extension('amp-brid-player', '0.1', (AMP) => {
497+
AMP.registerElement('amp-brid-player', AmpBridPlayer);
498+
AMP.registerElement('amp-target-video-player', AmpBridPlayer);
498499
});

extensions/amp-brid-player/0.1/test/test-amp-brid-player.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ describes.realWin(
2222
timer = Services.timerFor(win);
2323
});
2424

25-
function getBridPlayer(attributes, opt_responsive, config) {
26-
const bc = doc.createElement('amp-brid-player');
25+
function getBridPlayer(attributes, opt_responsive, config, alias = false) {
26+
const bc = alias
27+
? doc.createElement('amp-target-video-player')
28+
: doc.createElement('amp-brid-player');
2729

2830
for (const key in attributes) {
2931
bc.setAttribute(key, attributes[key]);
@@ -83,6 +85,26 @@ describes.realWin(
8385
});
8486
});
8587

88+
it('renders alias', () => {
89+
return getBridPlayer(
90+
{
91+
'data-partner': '264',
92+
'data-player': '4144',
93+
'data-video': '13663',
94+
},
95+
null,
96+
null,
97+
true
98+
).then((bc) => {
99+
const iframe = bc.querySelector('iframe');
100+
expect(iframe).to.not.be.null;
101+
expect(iframe.tagName).to.equal('IFRAME');
102+
expect(iframe.src).to.equal(
103+
'https://services.brid.tv/services/iframe/video/13663/264/4144/0/1/?amp=1'
104+
);
105+
});
106+
});
107+
86108
it('renders responsively', () => {
87109
return getBridPlayer(
88110
{

extensions/amp-brid-player/validator-amp-brid-player.protoascii

+54
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,57 @@ tags: { # <amp-brid-player>
6464
supported_layouts: RESPONSIVE
6565
}
6666
}
67+
tags: { # <amp-target-video-player>
68+
html_format: AMP
69+
tag_name: "AMP-TARGET-VIDEO-PLAYER"
70+
requires_extension: "amp-brid-player"
71+
attrs: { name: "autoplay" }
72+
attrs: {
73+
name: "data-dynamic"
74+
value_regex: "[a-z]+"
75+
}
76+
attrs: {
77+
name: "data-outstream"
78+
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
79+
value_regex: "[0-9]+"
80+
}
81+
attrs: {
82+
name: "data-partner"
83+
mandatory: true
84+
value_regex: "[0-9]+"
85+
}
86+
attrs: {
87+
name: "data-player"
88+
mandatory: true
89+
value_regex: "[0-9]+"
90+
}
91+
attrs: {
92+
name: "data-playlist"
93+
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
94+
value_regex: ".+"
95+
}
96+
attrs: {
97+
name: "data-video"
98+
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
99+
value_regex: "[0-9]+"
100+
}
101+
attrs: {
102+
name: "data-carousel"
103+
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
104+
value_regex: "[0-9]+"
105+
}
106+
attrs: {
107+
name: "dock"
108+
requires_extension: "amp-video-docking"
109+
}
110+
attr_lists: "extended-amp-global"
111+
spec_url: "https://amp.dev/documentation/components/amp-brid-player/"
112+
amp_layout: {
113+
supported_layouts: FILL
114+
supported_layouts: FIXED
115+
supported_layouts: FIXED_HEIGHT
116+
supported_layouts: FLEX_ITEM
117+
supported_layouts: NODISPLAY
118+
supported_layouts: RESPONSIVE
119+
}
120+
}

0 commit comments

Comments
 (0)