如何解决Twilio-Video:没有声音/没有音频,但视频正在运行
我正在研究如何使用 Twilio-Video 创建 Go 房间。视频连接运行良好,所以我猜令牌是有效的。但是没有音频。在两个方向。相关JS如下。
我已经浏览了各种指南和相关问题,但我不知道我哪里出错了。我认为令牌也有效,因为视频连接正常工作。在我测试的设备上,其他视频聊天应用程序运行良好。我什至测试了不同的浏览器,但都没有成功。
更新 1
我试图用 --autoplay-policy=no-user-gesture-required 启动 Chrome 来测试它是否是自动播放策略的问题。不幸的是,问题仍然存在。
更新 2
重新启动我的测试设备,没有任何成功。
更新 3
测试 https://networktest.twilio.com/ 和 https://webrtc.github.io/samples/src/content/devices/input-output/ 成功。
浏览器日志
如果我和对等方加入和离开视频通话,浏览器会记录日志。
[3998:82691:0530/053811.743187:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/053812.372684:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/053833.884230:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/053833.902541:ERROR:webrtc_video_engine.cc(3350)] Absent receive stream; ignoring clearing encoded frame sink for ssrc 0
[3998:47363:0530/053835.045916:ERROR:turn_port.cc(1855)] Received TURN CreatePermission error response,code=403; pruned connection.
[3998:47363:0530/053835.046129:ERROR:turn_port.cc(1855)] Received TURN CreatePermission error response,code=403; pruned connection.
[3998:82691:0530/053848.634515:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/055416.022796:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/055416.620048:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/055438.608201:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[3998:82691:0530/055438.615202:ERROR:webrtc_video_engine.cc(3350)] Absent receive stream; ignoring clearing encoded frame sink for ssrc 0
[3998:47363:0530/055439.651049:ERROR:turn_port.cc(1855)] Received TURN CreatePermission error response,code=403; pruned connection.
[3998:82691:0530/055458.482652:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4192:84227:0530/060006.499133:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4192:84227:0530/060007.109077:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4306:47107:0530/061047.578035:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4306:47107:0530/061048.547660:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4316:84227:0530/061145.241086:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4316:84227:0530/061145.792233:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4316:84227:0530/061153.197745:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4316:84227:0530/061153.206282:ERROR:webrtc_video_engine.cc(3350)] Absent receive stream; ignoring clearing encoded frame sink for ssrc 0
[4316:83971:0530/061154.219117:ERROR:turn_port.cc(1855)] Received TURN CreatePermission error response,code=403; pruned connection.
[4316:84227:0530/061215.332750:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
[4316:84227:0530/061215.926683:ERROR:audio_rtp_receiver.cc(88)] AudioRtpReceiver::OnSetVolume: No audio channel exists.
JS
let room;
// Called after page load.
const joinRoom = async (token,roomName) => {
const Video = Twilio.Video;
const localTracks = await Video.createLocalTracks({
audio: true,video: { width: 1280,height: 720 },});
try {
room = await Video.connect(token,{
name: roomName,tracks: localTracks,});
} catch (error) {
console.log(error);
}
const localMediaContainer = document.getElementById("local-media-container");
localTracks.forEach((localTrack) => {
localMediaContainer.appendChild(localTrack.attach());
});
try {
room.participants.forEach(onParticipantConnected);
room.on("participantConnected",onParticipantConnected);
room.on("participantdisconnected",onParticipantdisconnected);
} catch (error) {
console.log(error);
}
// Mute audio button
const muteBtn = document.getElementById('mute-btn');
const unmuteBtn = document.getElementById('unmute-btn');
muteBtn.onclick = function(event) {
try {
room.localParticipant.audioTracks.forEach(track => {
track.track.disable();
});
} catch (error) {
console.log(error);
}
muteBtn.classList.add('d-none');
unmuteBtn.classList.remove('d-none');
};
unmuteBtn.onclick = function(event) {
try {
room.localParticipant.audioTracks.forEach(track => {
track.track.enable();
});
} catch (error) {
console.log(error);
}
unmuteBtn.classList.add('d-none');
muteBtn.classList.remove('d-none');
};
// Stop video button
const stopVideoBtn = document.getElementById('stop-video-btn');
const startVideoBtn = document.getElementById('start-video-btn');
stopVideoBtn.onclick = function(event) {
try {
room.localParticipant.videoTracks.forEach(track => {
track.track.disable();
});
} catch (error) {
console.log(error);
}
stopVideoBtn.classList.add('d-none');
startVideoBtn.classList.remove('d-none');
};
startVideoBtn.onclick = function(event) {
try {
room.localParticipant.videoTracks.forEach(track => {
track.track.enable();
});
} catch (error) {
console.log(error);
}
startVideoBtn.classList.add('d-none');
stopVideoBtn.classList.remove('d-none');
};
};
const onParticipantdisconnected = (participant) => {
const participantDiv = document.getElementById("peer-media-container");
participantDiv.innerHTML = '<div class="d-flex flex-row w-100 h-100 align-items-center justify-content-center text-center text-white">Call ended.</div>';
};
const onParticipantConnected = (participant) => {
const participantDiv = document.getElementById("peer-media-container");
const trackSubscribed = (track) => {
participantDiv.innerHTML = "";
participantDiv.appendChild(track.attach());
};
participant.on("trackSubscribed",trackSubscribed);
participant.tracks.forEach((publication) => {
if (publication.isSubscribed) {
trackSubscribed(publication.track);
}
});
const trackUnsubscribed = (track) => {
track.detach().forEach((element) => element.remove());
};
participant.on("trackUnsubscribed",trackUnsubscribed);
};
const onLeaveButtonClick = (event) => {
room.localParticipant.tracks.forEach((publication) => {
const track = publication.track;
track.stop();
const elements = track.detach();
elements.forEach((element) => element.remove());
});
room.disconnect();
close();
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。