'Agora Flutter: Able to see video on local views, but on remote view other speaker see's black screen
I'm using flutter agora SDk, when trying on two phones, I can see the local video when turned on, but when a remote video is viewing the stream its a black screen for them. Here's the code for local & remote view display:
class _VideoCallWidgetState extends State<VideoCallWidget> {
@override
Widget build(BuildContext context) {
return BlocBuilder<VoiceChatCubit, VoiceChatState>(
buildWhen: (prev, curr) => prev.videoChatEnabledRtcIds != curr.videoChatEnabledRtcIds,
builder: (context, state) {
final myRtcUid = context.read<VoiceChatCubit>().myRtcChannelUid;
// No one's video is enabled
if (state.videoChatEnabledRtcIds.isEmpty) {
return Container();
} else {
// Single video participant
if (state.videoChatEnabledRtcIds.length == 1) {
// Only me as participant
if (state.videoChatEnabledRtcIds.contains(myRtcUid)) {
return GestureDetector(
onTap: () {
videoMethod(context, RtcLocalView.SurfaceView());
},
child: Container(
height: 200,
width: 120,
color: Colors.red,
child: RtcLocalView.SurfaceView(),
),
);
} else {
// Single participant (not me)
return GestureDetector(
onTap: () {
videoMethod(
context,
RtcRemoteView.SurfaceView(
channelId: state.roomTitle,
uid: state.videoChatEnabledRtcIds.first,
));
},
child: Container(
height: 200,
width: 120,
color: Colors.black,
child: RtcRemoteView.SurfaceView(
channelId: state.roomTitle,
uid: state.videoChatEnabledRtcIds.first,
),
),
);
}
Solution 1:[1]
I am not sure about the if condition that you're using state.videoChatEnabledRtcIds.contains(myRtcUid) since this will always will be true even when the remote user joins, so the else statement might not trigger.
Also, from the code I am not so sure what videoMethod is. Can you please share the code for that as well.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | meherdeep thakur |
