muaz-khan / MultiStreamsMixer

MultiStreamsMixer is a JavaScript library that allows you pass multiple streams (e.g. screen+camera or multiple-cameras) and get single stream.
https://www.webrtc-experiment.com/MultiStreamsMixer/
MIT License
436 stars 109 forks source link

Import MultiStreamsMixer Javascript file with dependency instead of script #7

Closed luanraithz closed 5 years ago

luanraithz commented 5 years ago

Is there way way of doing the following in a javascript file?

import MultiStreamsMixer from 'multistreamsmixer'
// or even: 
import { MultiStreamsMixer } from 'multistreamsmixer'

It worked importing the script in the with a script tag, but we are trying to avoid this kind of approach (put things in the window). I see that your MultStreamsMixer.ts file exports the class, are there any reason to don't do so at the js file?

luanraithz commented 5 years ago

Sadly the way it worked was download MultiStreamsMixer.js file manually, and change it so it exports what I need, but I think it's a really bad approach.

muaz-khan commented 5 years ago

I'll add import and require in the next commit. Something like this:

const MultiStreamsMixer = require('multistreamsmixer');
import { MultiStreamsMixer} from 'multistreamsmixer';
luanraithz commented 5 years ago

Ok, thanks a lot.

muaz-khan commented 5 years ago

Please install NPM package and test again. (npm install multistreamsmixer)

import { MultiStreamsMixer} from 'multistreamsmixer';
luanraithz commented 5 years ago

Yeap it works now, thanks. But you exported as:

 module.exports = MultiStreamsMixer;

So I have to import it as:

import MultiStreamsMixer from 'multistreamsmixer';

Do you intend to keep that way ? If so, the readme would have to be changed, I may change it and open a pull request if you don't want to bother with it.