小编paa*_*aan的帖子

typescript - 对象可能是'null'

我得到以下错误,但程序运行完美

错误

var video = document.querySelector('#camera-stream'),

if(!navigator.getMedia){
        displayErrorMessage("Your browser doesn't have support for the navigator.getUserMedia interface.");
    }
    else{
        // Request the camera.
        navigator.getMedia(
            {
                video: true
            },
            // Success Callback
            function(stream:any){

                // Create an object URL for the video stream and
                // set it as src of our HTLM video element.
                video.src = window.URL.createObjectURL(stream);

                // Play the video element to start the stream.
                video.play();
                video.onplay = function() {
                    showVideo();
                };

            },
            // Error Callback
            function(err:any){
                displayErrorMessage("There was an error with accessing …
Run Code Online (Sandbox Code Playgroud)

typescript angular

6
推荐指数
4
解决办法
1万
查看次数

标签 统计

angular ×1

typescript ×1