-
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
Implemented video-interface and autoplay for amp-brid-player #8632
Conversation
@DarXector Thanks for the PR, I will do a detailed review soon, meanwhile could you please add amp-bird-player to the video-interface integration tests and make sure they pass? To do so you need to: These will run an extensive suite of tests to ensure all the postMessages between the component and the iframe work properly. You can run the tests locally by running If you run into test failures, best way to debug manually is to add Adding |
@aghassemi This has been completed. |
@DarXector could you please rebase your PR (presubmit checks are failing and require a rebase to be fixed due to a backward-incompatible change we made couple of weeks ago) |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLAs look good, thanks! |
|
||
let feedType = ''; | ||
|
||
if (this.element.getAttribute('data-video')) { |
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.
#hasAttribute
|
||
if (this.element.getAttribute('data-video')) { | ||
feedType = 'video'; | ||
} else if (this.element.getAttribute('data-playlist')) { |
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.
#hasAttribute
|
||
this.playerReadyPromise_.then(() => { | ||
if (this.iframe_ && this.iframe_.contentWindow) { | ||
const args = typeof opt_arg !== 'undefined' ? '|' + opt_arg : ''; |
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.
Nit: const args = opt_arg === undefined ? '' : '|' + opt_arg;
/** @private */ | ||
handleBridMessages_(event) { | ||
|
||
if (event.origin.indexOf('services.brid.tv') == -1 || |
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.
Are there subdomains? Could this just be an equality check?
|
||
if (event.origin.indexOf('services.brid.tv') == -1 || | ||
event.source != this.iframe_.contentWindow || | ||
typeof event.data !== 'string' || event.data.indexOf('Brid') == -1) { |
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.
The data should start with Brid
, right?
@aghassemi @jridgewell I rebased the PR and adopted your observations. |
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 for adding video-interface support! Few requests and then we can merge after tests pass.
amp-brid-player/0.1/test/validator-amp-brid-player.html:47:2 The mandatory attribute 'data-player' is missing in tag 'amp-brid-player'. (see https://www.ampproject.org/docs/reference/components/media/amp-brid-player) [AMP_TAG_PROBLEM] | ||
amp-brid-player/0.1/test/validator-amp-brid-player.html:53:2 The tag 'amp-brid-player' is missing a mandatory attribute - pick one of ['data-playlist', 'data-video']. (see https://www.ampproject.org/docs/reference/components/media/amp-brid-player) [AMP_TAG_PROBLEM] | ||
amp-brid-player/0.1/test/validator-amp-brid-player.html:48:2 The mandatory attribute 'data-player' is missing in tag 'amp-brid-player'. (see https://www.ampproject.org/docs/reference/components/amp-brid-player) [AMP_TAG_PROBLEM] | ||
amp-brid-player/0.1/test/validator-amp-brid-player.html:55:2 The tag 'amp-brid-player' is missing a mandatory attribute - pick one of ['data-playlist', 'data-video']. (see https://www.ampproject.org/docs/reference/components/amp-brid-player) [AMP_TAG_PROBLEM] |
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.
@DarXector Tests seems to be failing due to /media/
being removed here
this.applyFillContent(iframe); | ||
this.element.appendChild(iframe); | ||
this.iframe_ = iframe; | ||
return this.loadPromise(iframe); | ||
|
||
this.win.addEventListener( |
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.
Please use
this.unlistenMessage_ = listen(
this.win,
'message',
this. handleBridMessages_.bind(this)
);
and define this.unlistenMessage_ in the contractor.
We also need a new unlayoutCallback
override that does:
/** @override */
unlayoutCallback() {
if (this.iframe_) {
removeElement(this.iframe_);
this.iframe_ = null;
}
if (this.unlistenMessage_) {
this.unlistenMessage_();
}
this.playerReadyPromise_ = new Promise(resolve => {
this.playerReadyResolver_ = resolve;
});
return true; // Call layoutCallback again.
}
'Brid|pause', | ||
'https://services.brid.tv' | ||
); | ||
this.pause(); |
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.
There shouldn't be a need to have the if
checks above as sendCommand_
and therefore pause
handles that.
|
||
/** | ||
* @implements {../../../src/video-interface.VideoInterface} |
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.
Since you now implement the video-interface, you will get autoplay
for free. Please
- Update the validation file to allow for autoplay attribute (
attrs: { name: "autoplay" }
) - Update the documentation MD file with:
**autoplay**
If this attribute is present, and the browser supports autoplay:
* the video is automatically muted before autoplay starts
* when the video is scrolled out of view, the video is paused
* when the video is scrolled into view, the video resumes playback
* when the user taps the video, the video is unmuted
* if the user has interacted with the video (e.g., mutes/unmutes, pauses/resumes, etc.), and the video is scrolled in or out of view, the state of the video remains as how the user left it. For example, if the user pauses the video, then scrolls the video out of view and returns to the video, the video is still paused.
- Update the example file to include autoplay and buttons for
play
,pause
,mute
,unmute
actions. Please seeamp-youtube.amp.html
inexamples
for reference.
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.
After doing this I get:
AssertionError: expected 'DISALLOWED_ATTR autoplay amp-brid-player' to equal ''
at C:/Users/Reesta/AppData/Local/Temp/e150422a9df00df6e8740f9f1e38f9a5.browserify:190016:38 <- D:/Ampps/www/amphtml/test/integration/test-example-validation.js:118:37
when running test.
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.
@honeybadgerdontcare Do you know what the best approach here is? We are adding a new attribute and using it in an example but looks like test-example-validation
uses the deployed validator rather than local. Should we not use the new attribute in an example until validator is deployed?
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.
According to test-example-validation.js there's a todo of using the local validator. Perhaps we should file an issue to use the local validator now that it is open-sourced.
Seems similar to #8859 where a new attribute was added and the integration test had to be skipped after the fact. Honestly I hadn't seen these integration tests till now (cc @Gregable as an fyi).
It may be best to add the integration test after the attribute is in the released validator and that can be tracked in a separate issue (as opposed to what happened with amp-pixel where there are several issues, one to skip then unskip).
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. @DarXector For now let's comment out brid-player.amp.html
in test-example-validation
and I will add it back when validator is in production.
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.
@aghassemi Done
@DarXector I tested this manually and only found one issue. Other than that, it looks great! |
this.win.addEventListener( | ||
'message', event => this.handleBridMessages_(event) | ||
); | ||
|
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.
please move this.element.appendChild(iframe);
here (so it is after the listener)
this. handleBridMessages_.bind(this) | ||
); | ||
|
||
this.win.addEventListener( |
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.
remove this, already listening above.
@DarXector Find another issue related to a race condition around
|
@aghassemi Concerning the unmute issue, I've identified the problem with value parsing on the player side. This has been reported to the dev team, and the fix will be released next week. As for the race issue, I was not able to reproduce this while testing on mobile or desktop environments. What devices/OS/browsers did you use? |
@DarXector I can't repro the race anymore either. Will let you know if I see it again. |
timer.promise(50).then(() => { | ||
const bridTimerIframe = bc.querySelector('iframe'); | ||
|
||
//console.log('getBridPlayer', bridTimerIframe.contentWindow); |
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.
remove
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.
please also rebase, there seems to be a git conflict.
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.
Rebased and removed the above code. Also we have pushed a new version with unmute fix.
@DarXector we can merge this while your team works on fixing unmute. |
@DarXector looks good. validator test is failing (related to |
amp-brid-player validator fix amp-brid-player added to test-video-players integration test amp-brid-player added to test-video-players integration test amp-brid-player incorporating suggestions from PR ampproject#8632 amp-brid-player validation fixes from PR ampproject#8632 amp-brid-player commented out brid-player.amp.html until validator is in production amp-brid-player removed unnecessary comment amp-brid-player removed extra message event listener amp-brid-player fixed urls in the validator file
@aghassemi Done. But not sure what happened to the amp-brid-player.md, I fixed it on my branch and it's now passing. I also did an interactive rebase. |
@DarXector |
@DarXector, I've landed a fix for the failing test that complained about amp-brid-player.md, so it should no longer be an issue. The link checker tool was mis-parsing links within script tags, so I've made it warning-only for now. You can ignore the warning and proceed. Sorry! |
@DarXector merged! |
@DarXector I was just playing around with the player, kudos! such a good video player! excellent UI and performance. video-interface implementation is working perfectly too. I also had a question, does brid player support captions? if so, we are thinking about implementing a feature where captions autoplay as well during muted autoplay ( #6376 ). If implementing this interests you please let me know and I will ping you when the internals are ready (on your end it would most likely be just implementing two new |
@aghassemi Thank you for the kind words, we are intent on improving it further. The player supports captions through a plugin and if the user supplied it through our CMS. So the feature should not be difficult to implement. On another note, when do you expect for the release with amp-brid-player autoplay/video-interface to go through? We already have partners interested in this feature. |
@DarXector it is currently in Dev Channel (to enable Dev Channel visit https://cdn.ampproject.org/experiments.html) and with Dev Channel enabled, For full production, probably ~3 weeks before |
Continuing from #8611
Implemented video-interface and autoplay for amp-brid-player.
Added brid-player to dep check whitelist
@aghassemi