-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
<amp-video-iframe> ✨ #16088
Conversation
7dc5001
to
9b53a93
Compare
var myVideo = document.querySelector('#my-video'); | ||
|
||
// For video.js: | ||
myIntegration.listenTo('videojs', myVideo); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
amphtml/spec/amp-shadow-doc.md
Lines 30 to 37 in 5446958
<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.
There was a problem hiding this comment.
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!
b175ab5
to
46980e1
Compare
7b89c43
to
f8a4331
Compare
f8a4331
to
23d0a86
Compare
00af2a4
to
c0d878a
Compare
Codecov Report
@@ 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.
|
ad29a38
to
f404457
Compare
@@ -37,6 +37,14 @@ let RuleConfigDef; | |||
// this in review. | |||
exports.rules = [ | |||
// Global rules | |||
{ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#16550 :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
Lines 77 to 88 in 6ec9b05
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(' ')); | |
} |
amphtml/src/video-iframe-integration.js
Lines 309 to 322 in 6ec9b05
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; | |
} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! #16563
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? |
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 , great news, thanks for letting me know. |
Ready for review.
Includes integration library (/cc @erwinmombay for serving).
Validation rules coming later per experimental support.
Autoplay