一款簡單實(shí)用的jQuery MP4視頻播放器代碼,網(wǎng)站MP4視頻在線播放插件。適用瀏覽器:360、FireFox、Chrome、Opera、傲游、搜狗、世界之窗. 不支持Safari、IE8及以下瀏覽器。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery MP4視頻播放器代碼</title> <!--封裝好的視頻布局樣式--> <link rel="stylesheet" href="css/jsmodern.min.css"> <script src="js/jquery.min.js"></script> <!--mp4視頻插件--> <script src="js/jsmodern.min.js"></script> <style> #video {width: 970px; height: 594px; margin: 0 auto; position: relative;} #video video {width: 100%; height: 100%; object-fit: fill;} .VideoBtn {position: absolute; left: 50%; top: 50%; display: block; width: 70px; height: 70px; margin-left: -35px; margin-top: -35px; cursor: pointer; z-index: 10;} </style> <!--視頻插件調(diào)用方法--> <script> $(function () { //視頻 jsModern.video("#video"); //播放視頻 $(".VideoBtn").click(function () { var video = document.getElementById("videoShow"); video.play(); $('.VideoBtn').hide(); }) //監(jiān)聽視頻的播放狀態(tài) var video = document.getElementById("videoShow"); video.oncanplay = function () { $(".VideoBtn").show(); //$("#video").attr("poster",""); } //視頻播放事件 video.onplay = function () { $("#videoShow").attr("poster", ""); $(".VideoBtn").hide(); }; video.onplaying = function () { $(".VideoBtn").hide(); }; //視頻暫停事件 video.onpause = function () { $(".VideoBtn").show(); }; //點(diǎn)擊視頻周圍暫停播放圖片出現(xiàn) video.onclick = function () { if (video.paused) { $(".VideoBtn").hide(); video.play(); } else { $(".VideoBtn").show(); video.pause(); } }; }) </script> </head> <body> <div id="video"> <video src="video.mp4" id="videoShow"></video> <span class="VideoBtn"><img src="images/bo1.png"></span> </div> </body> </html>
建站咨詢熱線
029-33273980