最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Getting "Not allowed to load local resource" error while trying to attach a MediaSource object as

programmeradmin1浏览0评论

I am trying to get this example to work. It works fine when I click the link. But when I try to download the HTML file on my local machine and try the same, it is throwing this error.

Not allowed to load local resource: blob:null/6771f68d-c4b8-49a1-8352-f2c277ddfbd4

The line of code that seems to be causing the issue is this,

video.src = window.URL.createObjectURL(mediaSource);

What this line of code is doing is basically trying to set the source of the video tag media element to the MediaSource object. I have tried various permutations without much luck.

I am using Chrome Version 28.0.1500.72 m, which is the latest stable release.

I would appreciate any pointers.

I am trying to get this example to work. It works fine when I click the link. But when I try to download the HTML file on my local machine and try the same, it is throwing this error.

Not allowed to load local resource: blob:null/6771f68d-c4b8-49a1-8352-f2c277ddfbd4

The line of code that seems to be causing the issue is this,

video.src = window.URL.createObjectURL(mediaSource);

What this line of code is doing is basically trying to set the source of the video tag media element to the MediaSource object. I have tried various permutations without much luck.

I am using Chrome Version 28.0.1500.72 m, which is the latest stable release.

I would appreciate any pointers.

Share Improve this question edited Jul 16, 2013 at 17:38 Mathew asked Jul 16, 2013 at 17:15 MathewMathew 6452 gold badges7 silver badges14 bronze badges 4
  • 14 run it from http: not file:... – dandavis Commented Jul 16, 2013 at 17:26
  • That worked! I just ported the file onto a http server and it worked fine. Looks like it some weird browser issue. @dandavis Thanks! – Mathew Commented Jul 16, 2013 at 21:55
  • @dandavis you should put that as an answer, I will upvote that, exactly as you briefly said. – Santiago Rebella Commented Mar 19, 2014 at 20:07
  • 2 run it from http: not file means: Fetch the page from a http server, instead of opening the html file locally. The browser (reasonably) has restrictions on local file access, which is why when the page is opened straight from your folder, you get the permission error. – user4584267 Commented May 29, 2017 at 14:34
Add a comment  | 

2 Answers 2

Reset to default 34

As @dandavis has said, "run it from http: not file".

I'm posting this as an answer for the sake of organization.

For starters: Running you project from http means having a http server (such as apache or a simple node http-server) and running your project via http://localhost.

Install http-server globally using npm command(provided you have installed Node.js in your system beforehand). Navigate to your file folder in CMD and type http-server. Your app should run in localhost:8080.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论