RecordRTC issue - stream only shows timestamp?

484 Views Asked by At

I'm rather new to the whole WebRTC thing, and I've been reading a ton of articles and about different APIs about how to handle video recording. It seems the more I read the more confusing the whole thing is. I know I can use solutions such as Nimbb, but I'd rather keep everything "in house", so to speak. The way I've got the code right now, the page loads and the user clicks a button to determine the type of input (text or video). When the video button is clicked, the webcam is initialized and turned on to record. However, the stream from the webcam doesn't show up in the page itself. It seems this is because the src of the video is actually an object. The weird thing is that when I try to get more info about the object by logging to console, I only get an object attribute called currentTime. How does this object create the actual source for the video element? I've tried many different variations of the code below to no avail, so I'm just wondering what I'm doing wrong.

var playerId = 'cam-'+t+'-'+click[1]+'-'+click[2];

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;

if(navigator.getUserMedia){
    function onSuccess(stream){
        var video = document.getElementById(playerId);
        var vidSource;

        if(window.webkitURL || window.URL){
            vidSource = (window.webkitURL) ? window.webkitURL.createObjectURL(stream) : window.URL.createObjectURL(stream);
        }else{
            vidSource = stream;
        }

        video.autoplay = true;
        video.src = vidSource;
    }

    function onError(e){
        console.error('Error: ', e);
    }

    navigator.getUserMedia({video: true, audio: true}, onSuccess, onError);
}else{
    //flash alternative
}
1

There are 1 best solutions below

0
On

The webkit check actually was the problem as pointed out by mido22 in the comments