Describe the bug
I am using the flutter uikit and I have an exception that occurs when the second user (with audience Role) joins a channel, where the part of the screen supposed to display the user's own camera displays" Remote uid can not be null or 0 Failed assertion: line 74 pos 16: 'canvas.uid != null && canvas.uid != 0'"
specifically on the video_view_controller.dart
To Reproduce
My VideoCallPage Code:
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
import 'package:agora_uikit/agora_uikit.dart';
import 'package:flutter/material.dart';
import 'package:naffsi/globals.dart' as globals;
import 'package:http/http.dart' as http;
import 'dart:convert';
const appId = "";
String serverUrl =
"https://agora-token-service-production-example.railway.app/";
int uid = 0;
int tokenRole = 1; // use 1 for Host/Broadcaster, 2 for Subscriber/Audience
int tokenExpireTime = 450; // Expire time in Seconds.
bool isTokenExpiring = false; // Set to true when the token is about to expire
class VideoCallPage extends StatefulWidget {
const VideoCallPage({Key? key,})
: super(key: key);
@override
State createState() => _VideoCallPageState();
}
class _VideoCallPageState extends State {
late String channelName;
late ClientRoleType role;
late AgoraClient client;
Future fetchToken(int uid, String channelName, int tokenRole) async {
// Prepare the Url
String url =
'$serverUrl/rtc/$channelName/${tokenRole.toString()}/uid/${uid.toString()}?expiry=${tokenExpireTime.toString()}';
// Send the request
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
// If the server returns an OK response, then parse the JSON.
Map<String, dynamic> json = jsonDecode(response.body);
String newToken = json['rtcToken'];
debugPrint('Token Received: $newToken');
// Use the token to join a channel or renew an expiring token
setToken(newToken);
} else {
// If the server did not return an OK response,
// then throw an exception.
throw Exception(
'Failed to fetch a token. Make sure that your server URL is valid');
}
Describe the bug I am using the flutter uikit and I have an exception that occurs when the second user (with audience Role) joins a channel, where the part of the screen supposed to display the user's own camera displays" Remote uid can not be null or 0 Failed assertion: line 74 pos 16: 'canvas.uid != null && canvas.uid != 0'" specifically on the video_view_controller.dart
To Reproduce My VideoCallPage Code:
import 'package:agora_rtc_engine/agora_rtc_engine.dart'; import 'package:agora_uikit/agora_uikit.dart'; import 'package:flutter/material.dart'; import 'package:naffsi/globals.dart' as globals; import 'package:http/http.dart' as http; import 'dart:convert';
const appId = "";
String serverUrl =
"https://agora-token-service-production-example.railway.app/";
int uid = 0;
int tokenRole = 1; // use 1 for Host/Broadcaster, 2 for Subscriber/Audience
int tokenExpireTime = 450; // Expire time in Seconds.
bool isTokenExpiring = false; // Set to true when the token is about to expire
class VideoCallPage extends StatefulWidget {
const VideoCallPage({Key? key,})
: super(key: key);
@override
State createState() => _VideoCallPageState();
}
class _VideoCallPageState extends State {
late String channelName;
late ClientRoleType role;
late AgoraClient client;
@override void initState() { super.initState(); initAgora(); }
void initAgora() async { client = AgoraClient( agoraEventHandlers: AgoraRtcEventHandlers( onTokenPrivilegeWillExpire: (connection, token) => fetchToken(uid, channelName, tokenRole), ), agoraConnectionData: AgoraConnectionData( appId: appId, channelName: "whatev", tokenUrl: serverUrl, uid: uid, ), agoraChannelData: AgoraChannelData( clientRoleType: globals.isPatient ? ClientRoleType.clientRoleAudience : ClientRoleType.clientRoleBroadcaster, )); await client.initialize(); }
Future fetchToken(int uid, String channelName, int tokenRole) async {
// Prepare the Url
String url =
'$serverUrl/rtc/$channelName/${tokenRole.toString()}/uid/${uid.toString()}?expiry=${tokenExpireTime.toString()}';
}
void setToken(String newToken) async { String token = newToken;
}
@override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Agora UI Kit'), centerTitle: true, ), body: SafeArea( child: Stack( children: [ AgoraVideoViewer( client: client, layoutType: Layout.floating, enableHostControls: true, // Add this to enable host controls ), AgoraVideoButtons( client: client, ), ], ), ), ), ); } }