Skip to content

Commit

Permalink
✨ Add TargetVideo Alias To Brid AMP Player (#40151)
Browse files Browse the repository at this point in the history
* Add TargetVideo Alias

* Lint, address PR comments

* Update validator, revert examples
  • Loading branch information
danijel-ristic authored Sep 19, 2024
1 parent 316898d commit 51f6e4c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
5 changes: 3 additions & 2 deletions extensions/amp-brid-player/0.1/amp-brid-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ class AmpBridPlayer extends AMP.BaseElement {
}
}

AMP.extension(TAG, '0.1', (AMP) => {
AMP.registerElement(TAG, AmpBridPlayer);
AMP.extension('amp-brid-player', '0.1', (AMP) => {
AMP.registerElement('amp-brid-player', AmpBridPlayer);
AMP.registerElement('amp-target-video-player', AmpBridPlayer);
});
26 changes: 24 additions & 2 deletions extensions/amp-brid-player/0.1/test/test-amp-brid-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ describes.realWin(
timer = Services.timerFor(win);
});

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

for (const key in attributes) {
bc.setAttribute(key, attributes[key]);
Expand Down Expand Up @@ -83,6 +85,26 @@ describes.realWin(
});
});

it('renders alias', () => {
return getBridPlayer(
{
'data-partner': '264',
'data-player': '4144',
'data-video': '13663',
},
null,
null,
true
).then((bc) => {
const iframe = bc.querySelector('iframe');
expect(iframe).to.not.be.null;
expect(iframe.tagName).to.equal('IFRAME');
expect(iframe.src).to.equal(
'https://services.brid.tv/services/iframe/video/13663/264/4144/0/1/?amp=1'
);
});
});

it('renders responsively', () => {
return getBridPlayer(
{
Expand Down
54 changes: 54 additions & 0 deletions extensions/amp-brid-player/validator-amp-brid-player.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,57 @@ tags: { # <amp-brid-player>
supported_layouts: RESPONSIVE
}
}
tags: { # <amp-target-video-player>
html_format: AMP
tag_name: "AMP-TARGET-VIDEO-PLAYER"
requires_extension: "amp-brid-player"
attrs: { name: "autoplay" }
attrs: {
name: "data-dynamic"
value_regex: "[a-z]+"
}
attrs: {
name: "data-outstream"
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
value_regex: "[0-9]+"
}
attrs: {
name: "data-partner"
mandatory: true
value_regex: "[0-9]+"
}
attrs: {
name: "data-player"
mandatory: true
value_regex: "[0-9]+"
}
attrs: {
name: "data-playlist"
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
value_regex: ".+"
}
attrs: {
name: "data-video"
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
value_regex: "[0-9]+"
}
attrs: {
name: "data-carousel"
mandatory_oneof: "['data-carousel', 'data-outstream', 'data-playlist', 'data-video']"
value_regex: "[0-9]+"
}
attrs: {
name: "dock"
requires_extension: "amp-video-docking"
}
attr_lists: "extended-amp-global"
spec_url: "https://amp.dev/documentation/components/amp-brid-player/"
amp_layout: {
supported_layouts: FILL
supported_layouts: FIXED
supported_layouts: FIXED_HEIGHT
supported_layouts: FLEX_ITEM
supported_layouts: NODISPLAY
supported_layouts: RESPONSIVE
}
}

0 comments on commit 51f6e4c

Please sign in to comment.