In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this article, the editor introduces in detail "how to use JS to control video effects in HTML5". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use JS to control video effects in HTML5" can help you solve your doubts.
The specific code is as follows:
Documenttitle > figcaption {text-align: center;line-height: 150pxposition: "Microsoft Yahei"; font-size: 24px;}. Player {width: 720pxX height: 360px margin: 10px auto;border: 1px solid # 000X position: relative;border-radius: 6px;}. Player video {width: 720pxash height: 360px;}. Controls {width: 700pxheight: 40pxscape: rgba (255Lo 255r 00.3); position: absolute;bottom: 10pxleft: 10pxborderside radius }. Switch {position: absolute;width: 22pxposition height: red;left: 10pxscape top: 9pxborderbenefit: radius: 50%;}. Progress {width: 432pxpolitics height: 10pxpolitics position: absolute;background-color: rgba; left: 40pxtranstop: 15pxborderscape radius: 4pxscape: hidden;}. Curr-progress {width: 0% height: 100% leadership color: # fff;. Time {width: 120pxscape height: 20pxtextscape alignment: center;line-height: 20px alignment Font-size: 12pxfigcaption color: # fff;position: absolute;left: 510pxtostop: 10px;}. Extend {position: absolute;width: 20pxten height: 20pxscape: red;right: 10pxscape top: 10px;} style > head > video case figcaption > video > a > div > div > 00:00:00span > / 00:00:00span > div > a > div > div > figure > var video = document.querySelector ('video'); var playBtn = document.querySelector (' .switch'); var currProgress = document.querySelector ('.curr-progress'); var currTime = document.querySelector (' curr-time') Var totalTime = document.querySelector ('.total-time'); var extend = document.querySelector (' .extend'); var tTime = 0 video.play playBtn.onclick = function () {if (video.paused) {/ / if the video is paused video.play (); / / play () play load () reload pause () pause} else {video.pause () }} / / when the video can be played (loaded over the network), video.oncanplay = function () {tTime = video.duration; / / get the total video duration (in seconds) var tTimeStr = getTimeStr (tTime); totalTime [XSS _ clean] = tTimeStr;} / / when the video current playback time is updated, video.ontimeupdate = function () {var cTime = video.currentTime; / get the current playback time var cTimeStr = getTimeStr (cTime); console.log (cTimeStr) CurrTime [XSS _ clean] = cTimeStr;currProgress.style.width = cTime/tTime*100+ "%";} extend.onclick = function () {video.webkitRequestFullScreen (); / / Video full screen} / / change the time in seconds to the string function getTimeStr (time) {var h = Math.floor (time/3600); var m = Math.floor (time%3600/60); var s = Math.floor (time%60); h = h > = 10 seconds: "0" + h M = m > = 10Secretm: "0" + m + s = s > = 10cm: "0" + s return h+ ":" + m + ":" + s;} script > body > html > read this, this article "how to use JS to control video effects in HTML5" has been introduced. If you want to master the knowledge of this article, you need to practice and use it before you can understand it. If you want to know more about related articles, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.