Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use JavaScript to add watermark to webpage video

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people don't understand the knowledge points of this article "How to add watermark to web video with JavaScript", so Xiaobian summarizes the following contents for everyone. The contents are detailed, the steps are clear, and they have certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "How to add watermark to web video with JavaScript".

principle

Through html page layout, at the video player level, through js control dom, insert text watermark code.

code example

index.html

html5 video watermark

00:00:00 / 00:00:00

$(".span").html("water-mark"); var video = document.querySelector("video"); var playBtn = document.getElementById("playBtn"); playBtn.onclick = function(){ if(video.paused){ video.play(); playBtn.src = "img/i-pause.png"; }else{ video.pause(); playBtn.src = "img/i-play.png"; } } var full = document.getElementById("full"); var container = document.getElementById("container"); var i = 1;//定义一个变量,用于记录是否为全屏状态 full.onclick = function(){ i++;//对2取余,为0则全屏,否则关闭全屏 if(i%2==0){//点击开启全屏 if(container.requestFullScreen){ container.requestFullScreen() }else if(container.webkitRequestFullScreen){ container.webkitRequestFullScreen()//谷歌 }else if(container.mozRequestFullScreen){ container.mozRequestFullScreen()//火狐 }else if(container.msRequestFullscreen){ container.msRequestFullscreen()//ie } $('video').css({"width":"100%","height":"100%"}); $(".pos").css("width","100%"); full.src = "img/i-exitfs.png"; }else{//关闭全屏 if(document.cancelFullscreen){ document.cancelFullscreen(); }else if(document.webkitCancelFullScreen){ document.webkitCancelFullScreen(); }else if(document.mozCancelFullScreen){ document.mozCancelFullScreen(); }else if(document.msExitFullscreen){ document.msExitFullscreen(); } $('video').css({"width":"640px","height":"360px"}); $(".pos").css("width","640px"); full.src = "img/i-fs.png"; } } function number1(s){ if(s

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report