Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Next Next commit
Add volume support in amp-video for amp-story.
  • Loading branch information
Ale Patron committed Oct 26, 2021
commit 4fc40b5615124fbe6369d3ee58adf4a1a0e9241a
22 changes: 22 additions & 0 deletions extensions/amp-story/1.0/media-pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,14 @@ export class MediaPool {
return Promise.resolve();
}

// When a video is muted, reset its volume to the default value of 1.
if (mediaType == MediaType.VIDEO) {
let parent = domMediaEl.parentElement;
if (parent) {
Comment thread
apatronl marked this conversation as resolved.
Outdated
domMediaEl.volume = 1;
}
}

return this.enqueueMediaElementTask_(poolMediaEl, new MuteTask());
}

Expand All @@ -870,6 +878,20 @@ export class MediaPool {
return Promise.resolve();
}

if (mediaType == MediaType.VIDEO) {
let parent = domMediaEl.parentElement;
Comment thread
apatronl marked this conversation as resolved.
Outdated
if (parent) {
let volume = parent.getAttribute('volume');
Comment thread
apatronl marked this conversation as resolved.
Outdated
if (volume) {
domMediaEl.volume = volume;
}
}

if (parent.getAttribute('noaudio')) {
domMediaEl.volume = 0;
}
}

return this.enqueueMediaElementTask_(poolMediaEl, new UnmuteTask());
}

Expand Down
4 changes: 4 additions & 0 deletions extensions/amp-video/validator-amp-video.protoascii
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ tags: { # <amp-video> in amp-story
name: "captions-id"
requires_extension: "amp-story-captions"
}
attrs: {
name: "volume"
value_regex: "^(?:0*(?:\.\d+)?|1(\.0*)?)$"
}
attr_lists: "extended-amp-global"
attr_lists: "amp-video-common"
spec_url: "https://amp.dev/documentation/components/amp-video/"
Expand Down