MediaStream已接收但未发送

问题描述

我正在使用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 (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...