Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add TargetVideo Alias To Brid AMP Player #40151

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions examples/brid-player.amp.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ <h4>Actions</h4>
<button on="tap:myVideo.unmute">Unmute</button>
<button on="tap:myVideo.fullscreen">Fullscreen</button>

<h2>Target Video Alias</h2>
<amp-target-video-player
id="tvPlayer"
data-partner="264"
data-player="4144"
data-video="13663"
layout="responsive"
width="480" height="270">
</amp-target-video-player>
<h4>Actions</h4>
<button on="tap:tvPlayer.play">Play</button>
<button on="tap:tvPlayer.pause">Pause</button>
<button on="tap:tvPlayer.mute">Mute</button>
<button on="tap:tvPlayer.unmute">Unmute</button>
<button on="tap:tvPlayer.fullscreen">Fullscreen</button>

<h2>Autoplay</h2>
<amp-brid-player
autoplay
Expand Down
2 changes: 2 additions & 0 deletions extensions/amp-brid-player/0.1/amp-brid-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {assertAbsoluteHttpOrHttpsUrl} from '../../../src/url';
import {VideoEvents_Enum} from '../../../src/video-interface';

const TAG = 'amp-brid-player';
const ALIAS = 'amp-target-video-player';

/**
* @implements {../../../src/video-interface.VideoInterface}
Expand Down Expand Up @@ -495,4 +496,5 @@ class AmpBridPlayer extends AMP.BaseElement {

AMP.extension(TAG, '0.1', (AMP) => {
AMP.registerElement(TAG, AmpBridPlayer);
AMP.registerElement(ALIAS, AmpBridPlayer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more proper to not use TAG or ALIAS here. TAG is used for logging (e.g: Log.i(TAG, 'some error message') ) Here it is declaring the extension's tag name, so they are not TAGs. Just fill amp-brid-player and amp-target-video-player as strings would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

});
19 changes: 17 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,8 @@ 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');
powerivq marked this conversation as resolved.
Show resolved Hide resolved

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

it('renders alias', () => {
return getBridPlayer({
powerivq marked this conversation as resolved.
Show resolved Hide resolved
'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
Loading