Disable HTML5 video download? [duplicate]

时光毁灭记忆、已成空白 提交于 2019-12-23 05:24:34

问题


How can you disable downloading a video in HTML5? I Do not understand this and anyway the question doesn't have a satisfactory answer


回答1:


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 this method or mine: make 2 cshtml pages: page and ogvpage (you have tagged your question asp.net). insert this code in page:

var request = UrlData[0];
if(Request.Cookies["allow"] != null){
Response.Redirect(Href("VIDEO PATH", request + ".mp4"));
}

and this in 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:

    <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);
}


来源:https://stackoverflow.com/questions/23344117/disable-html5-video-download

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!