微信浏览器自动播放视频(ios自动,安卓手点)
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>微信H5视频行内autoplay</title>
<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<style>
.aaa {
width: 300px;
height: 500px;
}
</style>
</head>
<body>
<div class="container">
<!-- For iOS -->
<video class="aaa" src="http://192.168.1.92:5500/白色.mp4" controls playsinline webkit-playsinline autoplay loop>
</video>
</div>
<script>
var player = document.querySelector('video')
window.onload = function () {
document.addEventListener('WeixinJSBridgeReady', () => {
player.play()
})
}
// 监听触摸移动事件
window.addEventListener('touchmove', function (event) {
console.log('Touch moved');
// 处理触摸移动的逻辑
player.play()
}, false);
// 监听触摸开始
window.addEventListener('touchstart', function (event) {
console.log('Touch moved');
// 处理触摸移动的逻辑
player.play()
}, false);
</script>
</body>
</html>