HTML5 Canvas - origin-clean标志如何设置为false? [英] HTML5 Canvas - How does the origin-clean flag get set to false?

查看:1600
本文介绍了HTML5 Canvas - origin-clean标志如何设置为false?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用HTML5 Canvas和Video,我一直遇到这个问题:我尝试演示和实验,但是我无法查看它们,除非我将它们上传到我的Web服务器。目前这不会造成很大的问题,因为我使用相对较小的文件,但我实际上正在准备一个更大的项目,这个问题会变得非常不方便很快。而且我只想直接得到我的事实。我一直在工作,我自己创建的视频和演示的那些。我使用的视频,我编码的年龄前,我工作与我编码的视频,之前使用它们在我的代码。它总是相同的结果,使用HTML5视频容器工程,使用Canvas中的视频不,Canvas不显示任何视频(除非,像我提到的,我上传他们到服务器)。



这是我到目前为止找到的信息:



http://html5doctor.com/video-canvas-magic/



http://www.whatwg.org /specs/web-apps/current-work/multipage/the-canvas-element.html#security-with-canvas-elements



(和



根据我的理解,我的画布必须被污染,我的文件不会被污染, t似乎是原始清洁,但这是我一直能够找出的。我不明白为什么。



有人知道更多这方面,可以解释这是如何和为什么这样工作吗?

http:// 加载的任何内容和从加载的任何内容之间,浏览器中有严格的分隔。 file:// URI。这实际上是相当明智的,否则从网络加载的随机页面将能够读取硬盘上的文件。还有一些其他限制,适用于 file:// URIs本身,这些也是为了不让您从网络下载的文件免费运行您的硬盘。



所有这一切,如果你的HTML文件和视频都坐在硬盘驱动器上的同一目录,那么一切仍然应该满足所有这些条件。



如果你仍然有问题,本地开发的一个有用的方法是使用轻量级的Web服务器。我个人使用 Python的SimpleHTTPServer ,因为它已经安装在我的机器上,但有很多其他 - 通常Web开发框架(例如Ruby on Rails)内置它们。


I started working with HTML5 Canvas and Video and I keep having this problem: I try demos and experiments but I can't view them unless I upload them to my web server. At the moment this doesn't pose a huge problem because I'm working with comparatively small files, but I'm actually preparing a bigger project, and this problem would become quite inconvenient very quickly. And also I would just like to get my facts straight. I have been working with both, my own created videos and those from demos. I worked with videos I encoded ages ago and I worked with videos I encoded a minute before using them in my code. It's always the same result, using the HTML5 Video container works, using video inside Canvas doesn't, Canvas just doesn't display any video (unless, like I mentioned, I upload them to a server).

This is the information I found so far:

http://html5doctor.com/video-canvas-magic/

http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#security-with-canvas-elements

(and a little bit of information on w3, but I'm not allowed to post more than two links)

From what I understand, my canvas must be tainted and my files don't appear to be 'origin-clean', but this is all I have been able to figure out. I don't understand why.

Does anybody know more about this and can explain how and why this works?

解决方案

There's a strict separation within browsers between anything loaded from http:// and anything loaded from a file:// URI. This is actually pretty sensible, otherwise random pages you loaded from the web would be able read files off your harddrive. There are several additional restrictions that apply to file:// URIs themselves, again these are aimed at not letting files you've downloaded from the web having free run of your harddrive.

Having said all that, if your HTML file and the videos are all sitting in the same directory on your harddrive then everything should still work as all these conditions should be met.

If you're still having problems, one useful approach for local development is to use a lightweight web server. Personally I use Python's SimpleHTTPServer because it was already installed on my machine, but there are many others - often web development frameworks (eg. Ruby on Rails) come with them built in.

这篇关于HTML5 Canvas - origin-clean标志如何设置为false?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆