javascript 禁用 HTML5 视频下载?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23344117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable HTML5 video download?
提问by javaseaayameradost
采纳答案by DividedByZero
Im not really Sure about your question but from what I understand, you want to stop people from downloading your html5 video. To do so you can Either use thismethod or mine: make 2 cshtml pages: page and ogvpage (you have tagged your question asp.net). insert this code in page:
我不太确定你的问题,但据我所知,你想阻止人们下载你的 html5 视频。为此,您可以使用此方法或我的方法:制作 2 个 cshtml 页面:page 和 ogvpage(您已标记了您的问题 asp.net)。在页面中插入此代码:
var request = UrlData[0];
if(Request.Cookies["allow"] != null){
Response.Redirect(Href("VIDEO PATH", request + ".mp4"));
}
and this in ogvpage:
这在 ogvpage 中:
var request = UrlData[0];
if(Request.Cookies["allow"] != null){
Response.Redirect(Href("VIDEO PATH", request + ".ogv"));
}
page 1 will serve the mp4 video and 2 will serve ogv. open the page you want video on and replace your video element with this:
第 1 页将提供 mp4 视频,第 2 页将提供 ogv。打开您想要播放视频的页面并用以下内容替换您的视频元素:
<video>
<source src="/page/video name without extention" type="video/mp4"/>
<source src="/ogvpage/video name without extention" type="video/ogv>
</video>
and finally put this at the top of your page:
最后把它放在页面的顶部:
if(Request.Cookies["allow"] == null){
HttpCookie myCookie = new HttpCookie("allow");
myCookie.Value = "true";
myCookie.Expires = DateTime.Now.AddSeconds(5);
Response.Cookies.Add(myCookie);
}