# Stream local media file from browser

**URL:** <https://discourse.lynckia.com/t/stream-local-media-file-from-browser/868>\
**Category:** Support\
**Created:** [November 16, 2018, 3:52pm UTC](https://discourse.lynckia.com/t/stream-local-media-file-from-browser/868 "2018-11-16T15:52:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkh](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.lynckia.com/mkh/32/38_2.png) [@mkh](https://discourse.lynckia.com/u/mkh)\
**Post date:** [November 16, 2018, 3:52pm UTC](https://discourse.lynckia.com/t/stream-local-media-file-from-browser/868/1 "2018-11-16T15:52:12Z")

</div>

It would be useful letting user to choose a media file from the local computer and stream it to other participants in the room. According to the [documentation](https://licode.readthedocs.io/en/master/client_api/) the Stream API supports file as an option:

```
var stream = Erizo.Stream({video: true, audio: false, url:"file:///path_to_file/movie.mkv"});

```

But since browsers do not allow to access local file due to security reasons so I assume the file is used by the MCU in the server side not the client.

One idea to create stream in the client is blob that can be generated by `URL.createObjectURL()`.

Another approach is [`MediaElement.captureStream()`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/captureStream) that creates a stream from the audio/video element. Then we need the API to support native MediaStream as input.

---

<div class="post-metadata">

**Author:** ![mkh](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.lynckia.com/mkh/32/38_2.png) [@mkh](https://discourse.lynckia.com/u/mkh)\
**Post date:** [November 17, 2018, 3:11am UTC](https://discourse.lynckia.com/t/stream-local-media-file-from-browser/868/2 "2018-11-17T03:11:21Z")

</div>

I could get it to work by creating an audio stream (`Erizo.Stream({ audio: true })`) and then overwriting the stream on `access-accepted` event:

```
stream.addEventListener('access-accepted', function(event) {
  stream.audio = true;
  stream.video = true;
  stream.stream = videoElement.captureStream();
});

```

But it’s kind of hack and I rather prefer to have an option for creating a fake stream for example by using an empty constraint (`{}`) and then set my desired stream before publishing it.
