✨ [amp-story-player] Re-emit captions state to host page#40506
Draft
michaeldegori wants to merge 1 commit into
Draft
✨ [amp-story-player] Re-emit captions state to host page#40506michaeldegori wants to merge 1 commit into
michaeldegori wants to merge 1 commit into
Conversation
Mirrors the existing amp-story-muted-state re-emit so host pages
embedding an amp-story can observe when the user toggles captions
inside the story.
* Adds CAPTIONS_STATE to STORY_MESSAGE_STATE_TYPE_ENUM.
* Subscribes to captions-state updates on handshake, alongside
muted-state.
* Routes inbound documentStateUpdate messages for CAPTIONS_STATE to
a new onCaptionsStateUpdate_ handler that dispatches an
'amp-story-captions-state' custom event with a {captions} detail
payload, matching the muted-state detail-key convention.
* Documents the new event in docs/spec/amp-story-player.md and
covers the on/off dispatch with two unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
<amp-story-player>re-emit of caption-state changes so host pages embedding a story can listen for caption toggles, mirroring the existingamp-story-muted-stateevent. The player already bridges muted-state from the embedded story to the host element viaonMutedStateUpdate_; this PR adds the captions-state equivalent.Changes to
src/amp-story-player/amp-story-player-impl.js, mirroring the muted-state plumbing:CAPTIONS_STATE: 'CAPTIONS_STATE'entry inSTORY_MESSAGE_STATE_TYPE_ENUM.messaging.sendRequest('onDocumentState', ...)subscription on handshake.casein theonDocumentStateUpdate_switch.onCaptionsStateUpdate_(captions)handler that dispatches anamp-story-captions-stateCustomEventon the player element with{captions}detail.Also updates
docs/spec/amp-story-player.mdand adds two unit tests intest/unit/test-amp-story-player.jsmirroring the existing muted-state tests.Host page usage:
Detail key is
captions(notcaptionsState) to match the muted-state external API, which drops the_STATEsuffix (MUTED_STATE→event.detail.muted). This PR is story-to-host re-emit only; a host-to-story push direction analogous toplayer.mute()/player.unmute()can be added in a follow-up if wanted.