如何解决Quickblox Flutter SDK-正在进行通话,但视频没有流
我是新手,它已经过去了几天,我正在努力使用alpha sdk进行视频通话。我可以拨打电话,可以听见音频,但不能播放视频(没有本地视频,也没有远程视频流)
所有权限都从设置中授予应用。
Android手机转android模拟器-音频正常工作,但没有视频 Android手机到Android手机-音频正常工作,但没有视频 Android手机转IOS模拟器-音频正常工作,但无视频。
-
SDK初始化很好
-
聊天已连接
-
WebRTC初始化在调用之前可以正常工作。
-
我进行视频通话,
startCall(opponentIds) async{ bool connected = await QB.chat.isConnected(); print('starting call'+connected.toString()); int sessionType = QBRTCSessionTypes.VIDEO; try { QBRTCSession session = await QB.webrtc.call(opponentIds,sessionType); print('starting call'+session.toString()); sessionId = session.id; play(myQBUserId,opponentIds[0],session.id); } on PlatformException catch (e) { print('error while initializing call'+e.toString()); } }
-
ListenforCall
_listenForCall() async { print('listening for call'); String eventName = QBRTCEventTypes.CALL; try { await QB.webrtc.subscribeRTCEvent(eventName,(data) async { Map<String,Object> payloadMap = new Map<String,Object>.from(data["payload"]); Map<String,Object> sessionMap = new Map<String,Object>.from(payloadMap["session"]); String sessionId = sessionMap["id"]; int initiatorId = sessionMap["initiatorId"]; int callType = sessionMap["type"]; setState(() { this.sessionId = sessionId; _incomingCall = true; }); play(myQBUserId,initiatorId,sessionId); }); await QB.webrtc.subscribeRTCEvent(QBRTCEventTypes.RECEIVED_VIDEO_TRACK,Object>.from(payloadMap["session"]); String sessionId = sessionMap["id"]; int initiatorId = sessionMap["initiatorId"]; int callType = sessionMap["type"]; print('receiving video even from initiator:'+initiatorId.toString()); this.sessionId = sessionId; setState(() { _callStarted = true; }); await QB.webrtc.enableAudio(sessionId,enable: true); await QB.webrtc.enableVideo(sessionId,enable: true); }); } on PlatformException catch (e) { print('error while listening for calls'+e.toString()); } }
-
接听电话
_acceptCall() async{ try { QBRTCSession session = await QB.webrtc.accept(sessionId); print('listening call'+session.id+',initiatorid:'+session.initiatorId.toString()); sessionId = session.id; play(myQBUserId,session.initiatorId,sessionId); setState(() { _callStarted = true; }); } on PlatformException catch (e) { // Some error occured,look at the exception message for more details } }
-
结束通话
_endCall() async{ try { QBRTCSession session = await QB.webrtc.hangUp(sessionId); setState(() { _callStarted = false; _incomingCall = false; }); } on PlatformException catch (e) { // Some error occured,look at the exception message for more details } }
-
来自-https://docs.quickblox.com/docs/flutter-video-calling#setup-video-chat-layouts
的视频通话布局
RTCVideoViewController _localVideoViewController; RTCVideoViewController _remoteVideoViewController; ... child: new Container( margin: new EdgeInsets.fromLTRB(10.0,10.0,10.0),width: 160.0,height: 160.0,child: RTCVideoView( onVideoViewCreated: _onLocalVideoViewCreated,),decoration: new Boxdecoration(color: Colors.black54),) ... child: new Container( margin: new EdgeInsets.fromLTRB(10.0,child: RTCVideoView( onVideoViewCreated: _onRemoteVideoViewCreated,) ... void _onLocalVideoViewCreated(RTCVideoViewController controller) { _localVideoViewController = controller; } void _onRemoteVideoViewCreated(RTCVideoViewController controller) { _remoteVideoViewController = controller; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。