Skip to content

🐛 [Story mediapool] Unmute mediapool swap#38208

Merged
mszylkowski merged 35 commits intoampproject:mainfrom
mszylkowski:unmute_mediapool_swap
May 23, 2022
Merged

🐛 [Story mediapool] Unmute mediapool swap#38208
mszylkowski merged 35 commits intoampproject:mainfrom
mszylkowski:unmute_mediapool_swap

Conversation

@mszylkowski
Copy link
Copy Markdown
Contributor

@mszylkowski mszylkowski commented May 17, 2022

Fixes #38206

Changes

  • Gain nodes are not created every time the video is unmuted (eg: going back and forth on a page with volume=0.5), only once per video max.
  • Gain nodes are not used to mute videos (noaudio attr or volume=0), we just keep the video muted (we don't run the UnmuteTask).
  • When resetting the videos, if the video has a GainNode, we set the volume to 1 (note that the video muted state is independent of this, so the video can remain muted even if the GainNode.gain.value = 1).

Known issues (will be documented):

When a video on a story has volume=x (0<x<1) that source will use gainNodes to implement the volume, which can be reused on other videos. All videos on the story need to have the crossorigin attribute if they come from other origins (due to CORS), and will need ACAO headers as necessary.

@mszylkowski mszylkowski self-assigned this May 17, 2022
@mszylkowski mszylkowski requested a review from gmajoulet May 18, 2022 17:41
@mszylkowski mszylkowski marked this pull request as ready for review May 18, 2022 17:41
@amp-owners-bot
Copy link
Copy Markdown

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/media-pool.js

@mszylkowski mszylkowski changed the title Unmute mediapool swap 🐛 [Story mediapool] Unmute mediapool swap May 18, 2022
Copy link
Copy Markdown
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

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

Can we just disconnect the gain node when going to a new video? We could reuse/reconnect the gain if needed.

@mszylkowski
Copy link
Copy Markdown
Contributor Author

mszylkowski commented May 19, 2022

Can we just disconnect the gain node when going to a new video? We could reuse/reconnect the gain if needed.

Good suggestion. If you specifically mean the GainNode->AudioContext.destination connection, we technically can disconnect and reconnect it multiple times, I don't know how much performance we're leaving on the table by keeping these nodes connected though. I'd make this a followup PR if we want since it adds some more logic (I'd do it on mute/unmute, connect or disconnect the gain node of a video if it uses the audio graph). We'd also want to check what connection is best to break (or both): MediaSourceElementNode->GainNode or GainNode->AudioContext.destination. This wouldn't replace the fix on this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Story mediapool] Reused videos with gain node stay muted after reuse

4 participants