Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
391e2d2
Add console logs for testing
coreymasanto Apr 18, 2022
5971f44
Merge branch 'main' into previewPlay
coreymasanto Apr 19, 2022
534ab01
Remove console logs
coreymasanto Apr 19, 2022
996860b
Enable stories to play when in the PREVIEW visibility state
coreymasanto Apr 20, 2022
f6ebd8a
Use whenFirstPreviewedOrVisible() instead of Promise.any
coreymasanto Apr 20, 2022
26dce88
Lint fix
coreymasanto Apr 20, 2022
130888e
Update test-amp-story.js
coreymasanto Apr 20, 2022
ff40301
Merge branch 'main' into previewPlay
coreymasanto Apr 20, 2022
d44bfe1
Lint fix
coreymasanto Apr 20, 2022
de56eb1
Update test-amp-video.js
coreymasanto Apr 20, 2022
5198930
Lint fix
coreymasanto Apr 20, 2022
caa2077
Remove unnecessary newline
coreymasanto Apr 20, 2022
b5199ec
Revert unnecessary ampdoc-impl.js changes
coreymasanto Apr 20, 2022
a73478c
Merge branch 'main' into previewPlay
coreymasanto Apr 20, 2022
acdbf0e
ampdoc-impl.js: Use Promise.race() instead of Promise.any(), and remo…
coreymasanto Apr 21, 2022
47ab4a9
amp-story.js: use || instead of includes(), and remove the unnecessar…
coreymasanto Apr 21, 2022
954e11d
Revert unnecessary amp-video.js changes
coreymasanto Apr 21, 2022
471d7d2
Revert test-amp-video.js changes
coreymasanto Apr 21, 2022
23f3ff0
Lint fixes
coreymasanto Apr 21, 2022
09ff7e8
Merge branch 'main' into previewPlay
coreymasanto Apr 21, 2022
a17cd59
Revert comment change
coreymasanto Apr 21, 2022
af78648
Enable amp-video to play in preview mode
coreymasanto Apr 27, 2022
8079a54
Revert previous commit, which will instead be its own PR
coreymasanto Apr 27, 2022
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
Prev Previous commit
Revert previous commit, which will instead be its own PR
  • Loading branch information
coreymasanto committed Apr 27, 2022
commit 8079a540774c395b2c2fff851d5f8c5712128486
43 changes: 4 additions & 39 deletions extensions/amp-story/1.0/amp-story-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* </code>
*/
import {CommonSignals_Enum} from '#core/constants/common-signals';
import {VisibilityState_Enum} from '#core/constants/visibility-state';
import {Deferred} from '#core/data-structures/promise';
import {removeElement} from '#core/dom';
import {whenUpgradedToCustomElement} from '#core/dom/amp-element-helpers';
Expand Down Expand Up @@ -650,32 +649,10 @@ export class AmpStoryPage extends AMP.BaseElement {
}

/**
* @return {!Promise} A promise that blocks until all playback media on the
* page have begun their layouts.
* @private
*/
waitForPlaybackMediaLayoutStart_() {
return this.waitForPlaybackMediaLayout_(true /* waitForLayoutStart */);
}

/**
* @return {!Promise} A promise that blocks until all playback media on the
* page have completed their layouts.
* @private
*/
waitForPlaybackMediaLayoutEnd_() {
return this.waitForPlaybackMediaLayout_(false /* waitForLayoutStart */);
}

/**
* @param {boolean} waitForLayoutStart Whether this method should only block
* until all playback media have begun their layouts, as opposed to
* having completed them.
* @return {!Promise} A promise that blocks until all playback media on the
* page have begun or completed their layouts, `waitForLayoutStart`.
* @return {!Promise}
* @private
*/
waitForPlaybackMediaLayout_(waitForLayoutStart) {
waitForPlaybackMediaLayout_() {
const mediaSet = toArray(
this.getMediaBySelector_(Selectors.ALL_PLAYBACK_AMP_MEDIA)
);
Expand All @@ -685,13 +662,10 @@ export class AmpStoryPage extends AMP.BaseElement {
switch (mediaEl.tagName.toLowerCase()) {
case 'amp-audio':
case 'amp-video':
const loadSignal = waitForLayoutStart
? CommonSignals_Enum.LOAD_START
: CommonSignals_Enum.LOAD_END;
const signal =
mediaEl.getAttribute('layout') === Layout_Enum.NODISPLAY
? CommonSignals_Enum.BUILT
: loadSignal;
: CommonSignals_Enum.LOAD_END;

whenUpgradedToCustomElement(mediaEl)
.then((el) => el.signals().whenSignal(signal))
Expand Down Expand Up @@ -1073,16 +1047,7 @@ export class AmpStoryPage extends AMP.BaseElement {
*/
registerAllMedia_() {
if (!this.registerAllMediaPromise_) {
const visibilityState = this.getAmpDoc().getVisibilityState();
const isPreview = visibilityState === VisibilityState_Enum.PREVIEW;
// In preview mode, the `amp-video` layout callback does not resolve
// because it is blocked on requests for origin sources that cannot be
// made in the SERP due to privacy concerns. So, instead of indefinitely
// blocking registration, we register media elements at layout start.
const waitForPlaybackMediaLayoutPromise = isPreview
? this.waitForPlaybackMediaLayoutStart_()
: this.waitForPlaybackMediaLayoutEnd_();
this.registerAllMediaPromise_ = waitForPlaybackMediaLayoutPromise.then(
this.registerAllMediaPromise_ = this.waitForPlaybackMediaLayout_().then(
() => this.whenAllMediaElements_((p, e) => this.registerMedia_(p, e))
);
}
Expand Down