Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include webrtc adapter js into Angular5 app

I need to include webrtc-adapter to my Angular 5 app.

What I need to do besides: npm install webrtc-adapter ?

Do I need to make any additional imports?

like image 472
Jack Hudzenko Avatar asked Jan 31 '18 12:01

Jack Hudzenko


2 Answers

As you said you have to install int via npm npm install webrtc-adapter, then you need to include it in your index.js (or other main entry file) simply by doing:

import "webrtc-adapter";

at the top of it.

If you are using webpack instead of importing it you could add this to your webpack config as follow:

  entry: {
    application: "src/index",
    vendor: [
      "webrtc-adapter"
    ]
  },

Here are some examples how I am doing it in my projects:

  • import directly in main entry file
  • using webpack

For an easy abstraction layer of WebRTC I recommend using peer-data

like image 55
vardius Avatar answered Nov 15 '22 07:11

vardius


Include import 'webrtc-adapter'; in every component or service that uses WebRTC.

Also you need to import two zone.js patches:

// rtc peer connection patch
import 'zone.js/dist/webapis-rtc-peer-connection';
// getUserMedia patch
import 'zone.js/dist/zone-patch-user-media';

If you are using angular-cli you should add these lines in polyfills.ts after import 'zone.js/dist/zone'; that's already in this file.

like image 24
Herman Fransen Avatar answered Nov 15 '22 08:11

Herman Fransen