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

<amp-video-iframe> ✨ #16088

Merged
merged 82 commits into from
Jul 3, 2018
Merged

Conversation

alanorozco
Copy link
Member

@alanorozco alanorozco commented Jun 15, 2018

Ready for review.

Includes integration library (/cc @erwinmombay for serving).

Validation rules coming later per experimental support.

Autoplay

autoplay

@alanorozco alanorozco changed the title (do not merge) <amp-video-iframe> ✨ <amp-video-iframe> ✨ Jun 25, 2018
@alanorozco alanorozco requested a review from aghassemi June 25, 2018 23:14
var myVideo = document.querySelector('#my-video');

// For video.js:
myIntegration.listenTo('videojs', myVideo);
Copy link
Contributor

@cvializ cvializ Jun 22, 2018

Choose a reason for hiding this comment

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

What is the difference in terms of effort between these "simple integrations" and a full video component?

The document living inside your iframe must include a small library:

```js
<script src="https://cdn.ampproject.org/v0/amp-video-iframe-integration-0.1.js" defer>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why defer, instead of the approach with async and global object with a push property? The shadowdoc API does this

<script async src="https://cdn.ampproject.org/shadow-v0.js"></script>
<!-- Wait for API to initialize -->
<script>
(window.AMP = window.AMP || []).push(function(AMP) {
// AMP APIs can be used now via "AMP" object.
});
</script>

e.g.

(window.AmpVideoIntegration = window.AmpVideoIntegration || []).push(onAmpIntegrationReady);
function onAmpIntegrationReady(myIntegration) { }

That way boilerplate is reduced and the publisher doesn't need to listen for the event or to construct a new instance.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this approach a lot better!

@codecov-io
Copy link

codecov-io commented Jun 29, 2018

Codecov Report

Merging #16088 into master will increase coverage by 0.89%.
The diff coverage is 76.51%.

@@            Coverage Diff             @@
##           master   #16088      +/-   ##
==========================================
+ Coverage   77.14%   78.04%   +0.89%     
==========================================
  Files         547      551       +4     
  Lines       39934    40280     +346     
==========================================
+ Hits        30807    31436     +629     
+ Misses       9127     8844     -283

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5fefe7f...2cec4fa. Read the comment docs.

@@ -37,6 +37,14 @@ let RuleConfigDef;
// this in review.
exports.rules = [
// Global rules
{
Copy link
Contributor

Choose a reason for hiding this comment

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

great preemptive thinking.

postIntersection_(messageId) {
const {time, intersectionRatio} = this.element.getIntersectionChangeEntry();

// Only post ratio > 0 when in autoplay range to prevent internal autoplay
Copy link
Contributor

Choose a reason for hiding this comment

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

good compromise solution.

`http://iframe.localhost:${port}/test/fixtures/served/video-iframe.html`);
}

function createVideoIframe(size = null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the null default value add anything? size is undefined by default, which is falsy, so the default value null looks redundant when there is only a falsy check.

Copy link
Member Author

Choose a reason for hiding this comment

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

#16550 :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! There are a few other places in this PR with the same pattern, but it's not super important. To me, it adds a bit of overhead when a reader has to evaluate whether the = null default value is significant or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you point to some other examples where the default value is extraneous, or the optional parameter pattern is followed?

Copy link
Contributor

@cvializ cvializ Jul 3, 2018

Choose a reason for hiding this comment

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

Sure, these were part of this PR and it looks like undefined and null would give the same behavior in these situations, which makes the = null unnecessary:

export function createFrameFor(video, src, name = null, sandbox = null) {
const {element} = video;
const frame =
htmlFor(element)`<iframe frameborder=0 allowfullscreen></iframe>`;
if (name) {
frame.setAttribute('name', name);
}
if (sandbox) {
frame.setAttribute('sandbox', sandbox.join(' '));
}

postToParent_(data, optCallback = null) {
const id = this.callCounter_++;
const completeData = Object.assign({id}, data);
if (!getMode(this.win_).test && this.win_.parent) {
this.win_.parent./*OK*/postMessage(completeData, '*');
}
if (optCallback) {
this.callbacks_[id] = optCallback;
}
return id;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! #16563

@alanorozco alanorozco merged commit 085e3c4 into ampproject:master Jul 3, 2018
@AmyLiversidge
Copy link

Hi @alanorozco , i see is merged to master but it's not released yet? Could you clarify your release process please and when we can expect this to be live?

@alanorozco
Copy link
Member Author

Hi @AmyLiversidge

The extension is ongoing validator release, see #19504 for updates.

If everything goes well you should be able to use this in production within the next couple of weeks.

@alanorozco alanorozco deleted the amp-video-iframe branch November 28, 2018 22:45
@AmyLiversidge
Copy link

@alanorozco , great news, thanks for letting me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants