32

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.

Mathew
  • 635
  • 2
  • 7
  • 14
  • 14
    run it from http: not file:... – dandavis Jul 16 '13 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 Jul 16 '13 at 21:55
  • @dandavis you should put that as an answer, I will upvote that, exactly as you briefly said. – Santiago Rebella Mar 19 '14 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. –  May 29 '17 at 14:34

2 Answers2

35

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.

harriyott
  • 10,505
  • 10
  • 64
  • 103
Filipe Merker
  • 2,428
  • 1
  • 25
  • 41
  • how am I supposed to do this? in my examplei'm recording the Media Stream and trying to set it to a Video Tag in the same instace. – Victor Ferreira Nov 13 '17 at 00:17
  • 1
    @VictorFerreira I know i'm late, but running from http means having a http server (such as apache or a simple node http-server) and running your project via **http**://localhost. This is the meaning of "running from http not file". Your problem is that you are opening the file html file directly, instead of opening it via http (: – Filipe Merker Feb 07 '18 at 16:06
0

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.

Clinton Roy
  • 2,659
  • 2
  • 10
  • 7