ios开启静音才能自动播放,播放后 关闭静音
<video-player
id="myVideo"
class="video-player vjs-custom-skin"
ref="videoPlayer"
:options="playerOptions"
:playsinline="playsinline"
webkit-playsinline="true"
x5-playsinline="true"
x5-video-orientation="landscape"
style="object-fit:fill;"
>
</video-player>
data() {
return {
playerOptions: {
muted: true,
},
};
methods: {
isIos() {
let u = navigator.userAgent;
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1;
let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
if (isIOS) {
return false;
} else {
return true;
}
},
computed: {
player() {
return this.$refs.videoPlayer.player;
},
playsinline() {
this.playerOptions.muted = false;
return this.isIos();
},
}
};