8

watch and use webrtc stream in the directive of the angular application

 2 years ago
source link: https://www.codesd.com/item/watch-and-use-webrtc-stream-in-the-directive-of-the-angular-application.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

watch and use webrtc stream in the directive of the angular application

advertisements

Implementing a webrtc based webapp using angular 1.x. The webrtc related functionality is abstracted within a service and the controller watches the variables in the service.

Within the service, when I set the stream (either local or remote) using $rootScope.$apply(), the watch function in the controller gets executed. However at the same time, I see the following error on the console.

vendor.44edef6c.js:5 TypeError: Illegal invocation
at P (vendor.44edef6c.js:3)
at P (vendor.44edef6c.js:3)
at P (vendor.44edef6c.js:3)
at o.$digest (vendor.44edef6c.js:6)
at o.$apply (vendor.44edef6c.js:6)
at scripts.d348f551.js:6
at Object.w [as emit] (scripts.d348f551.js:1)
at scripts.d348f551.js:2

This in only seen if I try to set the video element source, not when I make an audion webrtc call. Are there any issues when passing a webrtc stream object from the service and using? Below is the html

<video ng-src="{{localStream}}" autoplay muted></video>


I think that's because that stream URL is not a trusted one. You have to do something like this:

localStream = $sce.trustAsResourceUrl(window.URL.createObjectURL(localStream));


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK