简体   繁体   English

WebRTC getUserMedia加载时淡入

[英]WebRTC getUserMedia fadein when loaded

I am using webRTC like this to display a webcam 我正在使用像这样的webRTC来显示网络摄像头

streamnavigator.mediaDevices.getUserMedia({

    video: {
        facingMode: "user",
    }

}).then(function (stream) {

    var video = document.getElementById('cam-stream');
    video.srcObject = stream;

}).catch( function (error) {

    console.log("Camera Stream Error : " + error.name + " - " + error.message);

});

I am wanting to fade the video in once it is has been loaded, adding a fadetoggle to the video element fades it in before the video has started displaying. 我想在加载视频后使其淡入淡出,向视频元素添加一个淡入淡出fadetoggle以在视频开始显示之前淡入。

Is there any sort of callback I can use to only fade in once the stream has loaded and is displaying? 是否只有流加载和显示后才可以淡入的回调?

video.onloadeddata = () => console.log('loaded data');

should do the trick. 应该可以。 See the MDN documentation . 请参阅MDN文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM