名站网址导航为大家提供关于网站网页设计设计相关的的教程知识。
- 本篇文章具体介绍如下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, width=device-width"> <title>跟版网-视频自动播放</title> <style> html, body { width: 100%; height: 100%; } .video-container { width: 300px; height: 600px; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden; margin: 0 auto; } #video { display: block; width: 100%; } #mask { width: 100%; height: 100%; background: rgba(0, 0, 0, 0.83); position: absolute; top: 0; left: 0; z-index: 2; display: flex; flex-direction: row; justify-content: center; align-items: center; } .pop-container { width: 250px; height: 200px; background: white; border-radius: 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; } button { width: 50px; height: 30px; border-radius: 4px; } </style> </head> <body> <div class="video-container"> <video id="video" src="video.mp4"></video> </div> <div id="mask"> <div class="pop-container"> <p>页面内有自动播放视频 请注意流量</p> <button onclick="playVideo()">我知道了</button> </div> </div> <script> function playVideo() { document.getElementById('mask').style.display = 'none'; var video = document.querySelector('#video'); video.play(); } </script> </body> </html> |
<canvas id="canvas" height="750" width="750"></canvas> 页面加载完成的时候执行下面的js具体代码: var canvas = document.querySelector('#canvas'); // 注意这里需要将video.mp4转换成ts格式的文件 才能生效 var player = new JSMpeg.Player('video.ts', { canvas: canvas, loop: false, autoplay: false, audio: true }); player.audioOut.unlock(this.onUnlocked); player.play(); // onUnlocked方法 function onUnlocked() { player.volume = 1; } |
好了关于网站网页设计设计相关的这篇文章就给大家介绍到这里不明白的地方给本站留言。声明,本站内容来源于互联网,如果侵犯了你的权益请联系本站删除。,video,标签,设置,autoplay,在,手机,浏览器,织梦DedeCms做SEO优化必做的步骤