I'm not sure that is't the fair way, but finally, I found a way how to use it.

defining a file MediaStreamConstraints.as like this :

package
{
    [JSImport("MediaStreamConstraints")]
    public class MediaStreamConstraints
    {
        public var video:*;
        public var audio:*;
    }
}
Do the job

Le 2025-02-03 19:43, cont...@cristallium.com a écrit :

Hi All,

I'm not familiar with calling js functions directly in as3 code, so I struggle using

MediaDevices.getUserMedia(constraints:MediaStreamConstraints):Promise (https://developer.mozilla.org/fr/docs/Web/API/MediaDevices/getUserMedia)

I have issue with MediaStreamConstraints.

It's declared as interface on as3 side, so I tried to make a class with MediaStreamConstraints implementation.
I have this error When starting the app :

uncaught Error: Bad dependency path or symbol: MediaStreamConstraints
at visit (base.js:2796:17)
...

I also tried to pass required object {video:true;audio:false} directly (var constraint:* = { video: true, audio: false};) but I have this error when calling navigator.mediaDevices.getUserMedia(...) :
ReferenceError: MediaStreamConstraints is not defined

Here is the function:

private function myGetUserMedia(constraints:*):Promise {

return new Promise(function(resolve:Function, reject:Function):void {
/*var constraint:MyMediaStreamcontraints = new MyMediaStreamcontraints();
constraint.audio(false);
constraint.video(true);*/

var constraint:* = { video: true, audio: false};
navigator.mediaDevices.getUserMedia(constraint)
.then(function(stream:*):void {
resolve(stream);
})
.catch(function(error:*):void {
reject(error);
});
});

return null;
}

Do I miss something ?
Regards
-
Fred

Reply via email to