AgoraIO-Extensions / AgoraIO-Extensions/Agora-Flutter-SDK

Why i'm getting same remote id for multiple stream.

Aperta
#2,465 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Dart
Stelle
795
Fork
448
Merge medio
12h 19m
PR unite (30g)
14

Descrizione

I want to show the multiple video stream in one screen like cctv camera view. but only play the first stream and other remaining stream not playing.
I have notice one point is, i have do the loop to createAgoraRtcEngine each and every stream separately but getting same remote id for all the stream.

Please help me for this how i can play all the stream parallel.

below i have mention the code for understanding.


snapShot.requireData.forEach((element) async {
{
_playAutoPlay(cameraModel: element);
await Future.delayed(const Duration(seconds: 5));
}
});

void _playAutoPlay({required CCRoomAgoraModel cameraModel}) async
{
isLoaded = false;
await initAgora(cameraModel: cameraModel);
await Future.delayed(const Duration(milliseconds: 500));
await agoraStartStream(cameraModel: cameraModel);
roomController.update();
}

Future initAgora({required CCRoomAgoraModel cameraModel}) async {
try {
cameraModel.agoraEngine = createAgoraRtcEngine();
await cameraModel.agoraEngine!.initialize(
RtcEngineContext(
appId: CCConfig.agoraAppId,
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
),
);

// Enable video
await cameraModel.agoraEngine!.enableVideo();
cameraModel.isInitialized = true;
// Register event handler
cameraModel.agoraEngine!.registerEventHandler(
RtcEngineEventHandler(
onJoinChannelSuccess: (RtcConnection connection, int elapsed) {

},
onUserJoined: (RtcConnection connection, int remoteUid, int elapsed) {
CCPrint(name: "AgoraCheck", value: "Remote ID: ${remoteUid.toString()} == Camera Name: ${cameraModel.equipment_name} ",
);
cameraModel.remoteUid = remoteUid;
cameraModel.isLive = true;
setState(() {});
},
onUserOffline: (
RtcConnection connection,
int uid,
UserOfflineReasonType reason,
) {
CCPrint(name: "AgoraCheck", value: "onUserOffline");
cameraModel.isLive = false;
setState(() {});

},
onLeaveChannel: (RtcConnection connection, RtcStats stats) {
CCPrint(name: "AgoraCheck", value: "onLeaveChannel");

},
onError: (ErrorCodeType err, String msg) {

},
onRtcStats: (RtcConnection connection, RtcStats stats) {

},
),
);


} catch (e) {
CCPrint(name: "AgoraCheck", value: "init catch $e");
}
}

Future agoraStartStream({required CCRoomAgoraModel cameraModel}) async {
try {
// statusMessage.value = 'Connecting to broadcast...';

// Set user role as audience (viewer)
await cameraModel.agoraEngine!.setClientRole(
role: ClientRoleType.clientRoleAudience,
);

// Join channel
await cameraModel.agoraEngine!.joinChannel(
token: cameraModel.agora_token,
channelId: cameraModel.equipment_code.toString(),
uid: int.parse(cameraModel.remoteUid.toString()),
options: ChannelMediaOptions(
clientRoleType: ClientRoleType.clientRoleAudience,
autoSubscribeAudio: true,
autoSubscribeVideo: true,
publishMicrophoneTrack: false,
// Viewer doesn't send audio
publishCameraTrack: false,
// Viewer doesn't send video
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
),
);
setState(() {});
} catch (e) {
CCPrint(name: "AgoraCheck", value: "start catch $e");
}
}

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.