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

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

Offen
#2,465 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Dart
Sterne
795
Forks
448
Ø Merge
12 Std. 19 Min.
Gemergte PRs (30 T.)
14

Beschreibung

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");
}
}

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.