我的网站上有很多响应式的html5视频,我只想通过点击/点击视频来播放/暂停它们。它在桌面上是这样工作的,但在智能手机上,如果你点击视频,它只会显示控件,所以你需要再次点击控件才能播放/暂停。有没有办法让video.js播放器在移动设备上的表现像在桌面上一样。在视频(不是控件)上点击一次,播放第二次点击暂停。这是我的代码。请寻求帮助
<div class="wrapper">
<div style="max-width: 400px;margin:auto">
<video id="video1" class="video-js vjs-default-skin vjs-big-play-centered "
loop controls preload="auto" width="auto" height="auto"
poster="example.png"
data-setup='{"children": {"loadingSpinner": false}}'>
<source src="example.mp4" type='video/mp4' />
<source src="example.webm" type='video/webm' />
</video>
</div>
</div>发布于 2021-07-08 16:27:23
您可以禁用控件
videoJs('videoId', {controls: false});如果您禁用了控件,但希望点击视频暂停,您可以自定义触摸事件,that.play()是自定义方法
const that = this
this.videoObj = videojs(id, options, function () {
this.on('touchstart', function (e) {
if (e.target.nodeName === 'VIDEO') {
if (!that.isPlay) {
that.play()
} else {
that.pause()
}
}
})
})https://stackoverflow.com/questions/28070934
复制相似问题