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-bind: Support amp-youtube #8067

Merged
merged 5 commits into from
Mar 15, 2017

Conversation

dreamofabear
Copy link

Partial for #7825.

  • Support binding to amp-youtube's data-videoid attribute.

/to @aghassemi

@kmh287 kmh287 self-requested a review March 13, 2017 20:55
Copy link
Contributor

@kmh287 kmh287 left a comment

Choose a reason for hiding this comment

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

Can you please add a new test for this on the bind integration tests?

mutatedAttributesCallback(mutations) {
if (mutations['data-videoid'] !== undefined) {
this.videoid_ = this.getVideoId_();
if (this.iframe_) { // `null` if element hasn't been laid out yet.
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to refresh the iframe, YouTube supports dynamically loading a video which should be much faster than a full reload, the following should work (not tested though)

    this.playerReadyPromise_.then(() => {
      this.sendCommand_('loadVideoById', this.videoid_);
    });

Copy link
Author

Choose a reason for hiding this comment

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

Nice, thanks for pointing this out.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is short amount of time (actually a good 2 seconds, so not that short :) ) when this.iframe_ is not null but player is not loaded either (meaning commands will be ignored) wrapping the sendCommand_ in the this.playerReadyPromise_.then will queue it up in those cases.

Copy link
Author

Choose a reason for hiding this comment

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

I actually moved the this.playerReadyPromise_.then to within sendCommand_ to reduce duplication. I assume that we never want to call sendCommand_ before the player is ready as you mentioned.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

mutatedAttributesCallback(mutations) {
if (mutations['data-videoid'] !== undefined) {
this.videoid_ = this.getVideoId_();
if (this.iframe_) { // `null` if element hasn't been laid out yet.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is short amount of time (actually a good 2 seconds, so not that short :) ) when this.iframe_ is not null but player is not loaded either (meaning commands will be ignored) wrapping the sendCommand_ in the this.playerReadyPromise_.then will queue it up in those cases.

@dreamofabear
Copy link
Author

Can you please add a new test for this on the bind integration tests?

Done, though the added value isn't great since it doesn't test any logic within amp-youtube. That would probably require getVideoUrl YT API.

@dreamofabear
Copy link
Author

@kmh287 Gentle ping.

Copy link
Contributor

@kmh287 kmh287 left a comment

Choose a reason for hiding this comment

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

Just curious: do we need to also update the bind-validator to specify allowed protocols for amp-youtube like we do for amp-video?

@dreamofabear
Copy link
Author

Just curious: do we need to also update the bind-validator to specify allowed protocols for amp-youtube like we do for amp-video?

I don't think so since amp-brightcove.js constructs the URL from fragments like "account ID".

@dreamofabear dreamofabear merged commit 0aa63b3 into ampproject:master Mar 15, 2017
@dreamofabear dreamofabear deleted the bind-youtube branch March 15, 2017 16:12
mrjoro pushed a commit to mrjoro/amphtml that referenced this pull request Apr 28, 2017
* support binding to amp-youtube's data-videoid

* unit test

* use loadVideoById instead of changing iframe src

* fix lint error

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

Successfully merging this pull request may close these issues.

3 participants