[英]WebRTC : Remote peer stream is not getting render
我在運行遠程流時遇到困難。 我收到流對象 Ontrack 事件,但視頻沒有播放。 (自動運行是真的)這發生在一些對等點上,而不是所有對等點上。
peer.iceConnectionState 狀態更改為 'disconnected' 並且永遠不會回到連接狀態。
什么是這種情況的解決方案。
peer.ontrack = e => {
console.log('video is receiveing')
e.track.onunmute = () => {
console.log('track unmuted');
addVideoElement(userId, e.streams[0])
}
}
function addVideoElement(userId, stream) {
const existingVideoElement = document.getElementById(userId)
console.log('existingVideoElement ',existingVideoElement)
if(existingVideoElement) {
existingVideoElement.srcObject = stream
return
}
console.log('new element for user', userId)
const videoCointainer = document.getElementById('videoListContainer')
const videoElement = document.createElement('video')
videoElement.setAttribute('id',userId)
videoElement.srcObject = stream
videoElement.muted = 0
videoElement.autoplay = true
if(iOS) {
videoElement.playsInline = true
}
if (userId === socket.id) {
videoElement.volume = 0
}
videoCointainer.appendChild(videoElement)
shouldMute(false)
}
僅僅因為您獲得了一個流對象,這並不意味着建立了對等連接,這是接收要顯示的數據的先決條件。 如果您遇到的第一個冰連接狀態是“斷開連接”,則表示連接失敗。 添加 TURN 服務器會增加成功的機會。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.