Mute video when autoplay is blocked by browser policy #6087
2 changed files with 7 additions and 0 deletions
|
@ -38,6 +38,7 @@ export type Player = {
|
||||||
controlBar: {
|
controlBar: {
|
||||||
addChild: (string, any) => void,
|
addChild: (string, any) => void,
|
||||||
},
|
},
|
||||||
|
autoplay: (any) => boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -221,6 +221,12 @@ function VideoViewer(props: Props) {
|
||||||
);
|
);
|
||||||
|
|
||||||
Promise.race([playPromise, timeoutPromise]).catch((error) => {
|
Promise.race([playPromise, timeoutPromise]).catch((error) => {
|
||||||
|
if (typeof error === 'object' && error.name && error.name === 'NotAllowedError') {
|
||||||
|
if (player.autoplay() && !player.muted()) {
|
||||||
|
player.muted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PLAY_TIMEOUT_ERROR) {
|
if (PLAY_TIMEOUT_ERROR) {
|
||||||
const retryPlayPromise = player.play();
|
const retryPlayPromise = player.play();
|
||||||
Promise.race([retryPlayPromise, timeoutPromise]).catch((error) => {
|
Promise.race([retryPlayPromise, timeoutPromise]).catch((error) => {
|
||||||
|
|
Loading…
Reference in a new issue