webrtc / samples

WebRTC Web demos and samples
https://webrtc.github.io/samples
BSD 3-Clause "New" or "Revised" License
13.94k stars 5.71k forks source link

the video keeps not showing up #1666

Closed kun510 closed 3 months ago

kun510 commented 3 months ago

my code: peerConnection.ontrack = function(event) { console.log('Set up ontrack handler successfully'); console.log('Received remote stream event:', event); console.log('Received remote stream:', event.streams[0]); console.log('MediaStream tracks:', event.streams[0].getTracks()); event.streams[0].getVideoTracks().forEach(track => { track.enabled = true; });

            try {
                if(event.streams && event.streams[0]) {
                   video.srcObject = event.streams[0];
                  console.log('Video srcObject set to remote stream');
                  console.log('Video srcObject:', video.srcObject);
                }else{
                    console.log('No stream found');
                }
            } catch (error) {
                console.error('Error setting srcObject:', error);
            }
        };
Log:
Set up ontrack handler successfully

(index):125 Received remote stream event: RTCTrackEvent {isTrusted: true, receiver: RTCRtpReceiver, track: MediaStreamTrack, streams: Array(1), transceiver: RTCRtpTransceiver, …}isTrusted: truebubbles: falsecancelBubble: falsecancelable: falsecomposed: falsecurrentTarget: RTCPeerConnection {localDescription: RTCSessionDescription, currentLocalDescription: RTCSessionDescription, pendingLocalDescription: null, remoteDescription: RTCSessionDescription, onerror: ƒ, …}defaultPrevented: falseeventPhase: 0receiver: RTCRtpReceiver {track: MediaStreamTrack, transport: RTCDtlsTransport, rtcpTransport: null, playoutDelayHint: null, jitterBufferTarget: null}returnValue: truesrcElement: RTCPeerConnection {localDescription: RTCSessionDescription, currentLocalDescription: RTCSessionDescription, pendingLocalDescription: null, remoteDescription: RTCSessionDescription, onerror: ƒ, …}streams: [MediaStream]target: RTCPeerConnection {localDescription: RTCSessionDescription, currentLocalDescription: RTCSessionDescription, pendingLocalDescription: null, remoteDescription: RTCSessionDescription, onerror: ƒ, …}timeStamp: 9550track: MediaStreamTrack {kind: 'video', id: '63f076da-8d01-4338-a574-8fbacb71f748', label: '63f076da-8d01-4338-a574-8fbacb71f748', enabled: true, muted: true, …}transceiver: RTCRtpTransceiver {mid: '0', sender: RTCRtpSender, receiver: RTCRtpReceiver, stopped: false, direction: 'recvonly', …}type: "track"[[Prototype]]: RTCTrackEvent (index):126 Received remote stream: MediaStream {id: '1840e418-9a27-40d2-9c04-98db65d6b45e', active: true, onaddtrack: null, onremovetrack: null, onactive: null, …}active: trueid: "1840e418-9a27-40d2-9c04-98db65d6b45e"onactive: nullonaddtrack: nulloninactive: nullonremovetrack: null[[Prototype]]: MediaStream (index):127 MediaStream tracks: [MediaStreamTrack] (index):135 Video srcObject set to remote stream


It clearly has data but it doesn't display the video image

Screenshot 2024-06-25 105152

fippo commented 3 months ago

Not related to the samples, as noted in the deleted template this repository is not a general support place for WebRTC

Yaqing2023 commented 1 week ago

Have you found a solution for your issue? I ran into something similar, a video sent from machine A to machine B, I ca see track added and media Stream live, etc, but the video just not play on machine B.