Skip to content

Commit

Permalink
Mute videos on iOS devices when tapped
Browse files Browse the repository at this point in the history
  • Loading branch information
danielraffel authored and paulirish committed Mar 3, 2024
1 parent 1a76a7a commit 63db2dc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lite-yt-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class LiteYTEmbed extends HTMLElement {
const params = new URLSearchParams(this.getAttribute('params') || []);
params.append('autoplay', '1');
params.append('playsinline', '1');
if (/iPad|iPhone|iPod/.test(navigator.platform)) {
params.append('mute', '1'); // Mute only if on iPad or iPhone
}
return params;
}

Expand Down

0 comments on commit 63db2dc

Please sign in to comment.