问题描述
我正在使用videochat应用程序,并且所有内容都可以在桌面上运行,但是在iOS Safari中,我无法在页面加载时发送MediaStream。当页面在另一侧的iOS设备上挂载时,我只是得到此日志https://share.getcloudapp.com/RBuOpdL0和empy MediaStream(没有视频和音频)。有什么建议吗?
useEffect(() => {
if (isLoaded && !peer && isCamera) {
enqueueSnackbar('start peer');
peer = new Peer(
chatType === 'blogger'
? `blogger-${chatInfo.secret}`
: `fan-${chatInfo.secret}`,{
host: 'api.video-app',path: '/peer/conntact',port: '',secure: true,debug: 3,}
);
peer.on('call',(call) => {
// Answer the call with your own video/audio stream
setIsVideo(true);
call.answer(window.localStream);
// Receive data
call.on('stream',(stream) => {
console.log(stream);
// Store a global reference of the other user stream
window.peer_stream = stream;
// display the stream of the other user in the peer-camera video element !
peerCameraRef.current.srcObject = stream;
});
});
}
},[isLoaded,peer,chatInfo,isCamera]);
useEffect(() => {
const connectionInterval = setInterval(() => {
if (peer && !conn && chatInfo && isCamera) {
conn = peer.connect(
chatType === 'blogger'
? `fan-${chatInfo.secret}`
: `blogger-${chatInfo.secret}`,{
Metadata: {
username:
chatType === 'fan'
? chatInfo.user.name
: chatInfo?.interlocutor,},serialization: 'json',}
);
setIsConnected(true);
}
},2000);
return () => {
clearInterval(connectionInterval);
};
},[peer,conn,isCamera]);
useEffect(() => {
callInterval = setInterval(() => {
if (peer && conn && isConnected && !isCalled && chatInfo) {
setIsCalled(true);
const call = peer.call(
chatType === 'blogger'
? `fan-${chatInfo.secret}`
: `blogger-${chatInfo.secret}`,window.localStream
);
if (call) {
clearInterval(callInterval);
call.on('stream',(stream) => {
setIsVideo(true);
window.peer_stream = stream;
peerCameraRef.current.srcObject = stream;
});
}
}
},2000);
return () => {
clearInterval(callInterval);
};
},isConnected,isCalled,chatInfo]);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)