triniwiz / nativescript-webrtc

Apache License 2.0
42 stars 25 forks source link

webRTC.getUserMedia() returns me some weird array #43

Closed Argus444 closed 4 years ago

Argus444 commented 4 years ago

Which platform(s) does your issue occur on?

What type of device?

Version Numbers:

The problem: My front camera pops up which helped me make sure that camera is started. I used webRTC.getUserMedia() to store the incoming mediastream into a variable. But it returns something which I am sure is not not even close to how mediastreams usually are. This is how it looks: [b5ee0bd9-bde8-4520-b9fd-60b719bf33bb:A=1:V=1]

How to reproduce: On press of a button I check for WebRTC.hasPermissions(). once it fulfils the hasPermission, I invoke webRTC.getUserMedia()

code Involved: var WebRTC = require('nativescript-webrtc-plugin').WebRTC WebRTC.init(); const webRTC = new WebRTC({ enableAudio:true, enableVideo:false, iceServers : [ { 'url': 'stun:stun.l.google.com:19302' }, { 'url': 'xyz', 'username': 'xyz', 'credential': 'xyz' } ] })

onTap(){ if(!WebRTC.hasPermissions()){ try{ WebRTC.requestPermissions(); }catch(e){ console.log(e) } } let localstream = await webRTC.getUserMedia(); console.log(localstream) }

triniwiz commented 4 years ago

I need to add a deprecated to that class because the v2 way is the only classes that's being supported so please try the v2 demo located here

Argus444 commented 4 years ago

I need to add a deprecated to that class because the v2 way is the only classes that's being supported so please try the v2 demo located here

Thank You for your quick reply. I tried and used the following code: public setUpUserMedia() { const video = new Map(); video.set('facingMode', 'user'); this.cameraPosition = 'user'; video.set('width', 960); video.set('height', 720); const constraints = new TNSRTCMediaStreamConstraints(true, video); TNSRTCMediaDevices.getUserMedia(constraints) .then(mediaStream => { this.localStream = mediaStream; this.localView.srcObject = mediaStream; }) .catch(error => { console.log(error); }); }

I did a console.log for mediaStream. I get the following output: { "_stream": {} }

Am I missing some thing

triniwiz commented 4 years ago

That’s fine it just need to be used by the correct class/methods

Argus444 commented 4 years ago

That’s fine it just need to be used by the correct class/methods

Thank you once again, it works flawless I will close this issue Thank you for your support