BT1*_*101 1 javascript safari video.js vue.js vuejs2
在我的网站上,我有使用 video.js 库的 vue-video-player。在三星 Galaxy s9 的移动版 chrome 上,它可以正确自动播放,但在 iphone 7 的移动版 Safari 上无法自动播放。
HTML是:
<video-player class="video-player-box"
id="player"
ref="videoPlayer"
:options="playerOptions"
@ended="onPlayerEnded($event)">
</video-player>
Run Code Online (Sandbox Code Playgroud)
在我的脚本标签中:
data() {
return {
playerOptions: {
muted: true,
autoplay: true,
controls: false,
sources: [{
type: "video/mp4",
src: "https://res.cloudinary.com/dlqvkenro/video/upload/v1544320787/gvnn.mp4"
}],
poster: "/static/images/author.jpg",
}
}
},
Run Code Online (Sandbox Code Playgroud)
实际上在 safari 中,当我单击声音图标视频开始播放时,我希望它在用户进入页面时自动启动。
我添加了代码来以编程方式启动播放器:
mounted() {
this.player.play()
.then(() => {
console.log('play succseed');
})
.catch(() => {
alert('safari prevent player');
});
},
Run Code Online (Sandbox Code Playgroud)
实际上在 safari 中出现警报。有什么办法可以战胜苹果吗?
| 归档时间: |
|
| 查看次数: |
4707 次 |
| 最近记录: |