diff --git a/TRTC-API-Example/android/app/build.gradle b/TRTC-API-Example/android/app/build.gradle
index 5f29f9d..d3561c3 100644
--- a/TRTC-API-Example/android/app/build.gradle
+++ b/TRTC-API-Example/android/app/build.gradle
@@ -24,7 +24,7 @@ if (flutterVersionName == null) {
}
android {
- namespace = "com.tencent.trtcflutterapidemo"
+ namespace = "io.trtc.flutter.apiexample"
compileSdk = 35
ndkVersion = flutter.ndkVersion
@@ -44,7 +44,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId = "com.tencent.trtcflutterapidemo"
+ applicationId = "io.trtc.flutter.apiexample"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = flutter.minSdkVersion
diff --git a/TRTC-API-Example/android/app/src/main/AndroidManifest.xml b/TRTC-API-Example/android/app/src/main/AndroidManifest.xml
index a4411b4..74537b5 100644
--- a/TRTC-API-Example/android/app/src/main/AndroidManifest.xml
+++ b/TRTC-API-Example/android/app/src/main/AndroidManifest.xml
@@ -16,7 +16,7 @@
init() async {
+ _prefs = await SharedPreferences.getInstance();
+ _roomId = _prefs.getString('room_id') ?? _roomId;
+ _userId = _prefs.getString('user_id') ?? _userId;
+ }
+
+ static String get roomId => _roomId;
+ static set roomId(String v) { _roomId = v; _prefs.setString('room_id', v); }
+
+ static String get userId => _userId;
+ static set userId(String v) { _userId = v; _prefs.setString('user_id', v); }
+}
diff --git a/TRTC-API-Example/lib/main.dart b/TRTC-API-Example/lib/main.dart
index 635b99c..5c87093 100644
--- a/TRTC-API-Example/lib/main.dart
+++ b/TRTC-API-Example/lib/main.dart
@@ -1,9 +1,12 @@
+import 'package:api_example/common/app_config.dart';
import 'package:api_example/router/router_page.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
-void main() {
+void main() async {
+ WidgetsFlutterBinding.ensureInitialized();
+ await AppConfig.init();
runApp(const MyApp());
}
diff --git a/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_prepare_page.dart
index 4f8de1a..64ecdff 100644
--- a/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'audio_quality_page.dart';
+import 'package:api_example/common/app_config.dart';
class AudioQualityPreparePage extends StatefulWidget {
const AudioQualityPreparePage({Key? key}) : super(key: key);
@@ -10,8 +11,8 @@ class AudioQualityPreparePage extends StatefulWidget {
class _AudioQualityPreparePageState extends State {
final _formKey = GlobalKey();
- final _userIdController = TextEditingController();
- final _roomIdController = TextEditingController();
+ final _userIdController = TextEditingController(text: AppConfig.userId);
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
void dispose() {
@@ -55,7 +56,6 @@ class _AudioQualityPreparePageState extends State {
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.meeting_room),
),
- keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter room ID';
@@ -67,6 +67,8 @@ class _AudioQualityPreparePageState extends State {
ElevatedButton(
onPressed: () {
if (_formKey.currentState?.validate() ?? false) {
+ AppConfig.roomId = _roomIdController.text;
+ AppConfig.userId = _userIdController.text;
Navigator.push(
context,
MaterialPageRoute(
diff --git a/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_state.dart b/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_state.dart
index ff47697..ffb412c 100644
--- a/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/audio_quality/audio_quality_state.dart
@@ -86,7 +86,7 @@ class AudioQualityState extends ChangeNotifier {
_trtcCloud?.enterRoom(TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: int.parse(roomId),
+ strRoomId: roomId,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(userId)
), TRTCAppScene.voiceChatRoom);
diff --git a/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_page.dart b/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_page.dart
index 8ef0ce6..490d6cb 100644
--- a/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_page.dart
@@ -5,6 +5,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'local_record_state.dart';
import '../../../../common/user_list_widget.dart';
import '../../../../common/user_list_state.dart';
+import 'package:api_example/common/app_config.dart';
class LocalRecordPage extends StatefulWidget {
const LocalRecordPage({Key? key}) : super(key: key);
@@ -18,11 +19,17 @@ class _LocalRecordPageState extends State with SingleTickerProv
late LocalRecordState _localRecordState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
_localRecordState = LocalRecordState();
+ _localRecordState.roomId = _roomIdController.text;
+ _localRecordState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -35,6 +42,8 @@ class _LocalRecordPageState extends State with SingleTickerProv
void dispose() {
_tabController.dispose();
_localRecordState.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
_userListState?.dispose();
super.dispose();
}
@@ -136,9 +145,9 @@ class _LocalRecordPageState extends State with SingleTickerProv
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
+ controller: _roomIdController,
onChanged: (value) {
- _localRecordState.roomId = int.tryParse(value) ?? 0;
+ _localRecordState.roomId = value;
},
),
const SizedBox(height: 16),
@@ -148,6 +157,7 @@ class _LocalRecordPageState extends State with SingleTickerProv
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
+ controller: _userIdController,
onChanged: (value) {
_localRecordState.localUserId = value;
},
diff --git a/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_state.dart b/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_state.dart
index b2665cc..2f41b8b 100644
--- a/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/local_record/local_record_state.dart
@@ -15,7 +15,7 @@ class LocalRecordState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
UserListState? userListState;
ValueNotifier isEnterRoom = ValueNotifier(false);
@@ -64,7 +64,7 @@ class LocalRecordState extends ChangeNotifier {
}
void enterRoom() {
- if (localUserId == null || roomId == null) {
+ if (localUserId == null || roomId == null || roomId!.isEmpty) {
print("VideoContentState localUserId or roomId is null");
Fluttertoast.showToast(msg: "User ID or Room ID cannot be empty");
return;
@@ -74,7 +74,7 @@ class LocalRecordState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: localUserId!,
- roomId: roomId!,
+ strRoomId: roomId!,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_page.dart b/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_page.dart
index 8757dfd..3fcbba8 100644
--- a/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_page.dart
@@ -5,6 +5,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'render_params_state.dart';
import '../../../../common/user_list_widget.dart';
import '../../../../common/user_list_state.dart';
+import 'package:api_example/common/app_config.dart';
class RenderParamsPage extends StatefulWidget {
const RenderParamsPage({Key? key}) : super(key: key);
@@ -18,11 +19,17 @@ class _RenderParamsPageState extends State with SingleTickerPr
late RenderParamsState _renderParamsState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this); // Adjusted to 3 Tabs
_renderParamsState = RenderParamsState();
+ _renderParamsState.roomId = _roomIdController.text;
+ _renderParamsState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -35,6 +42,8 @@ class _RenderParamsPageState extends State with SingleTickerPr
void dispose() {
_tabController.dispose();
_renderParamsState.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
_userListState?.dispose();
super.dispose();
}
@@ -138,9 +147,9 @@ class _RenderParamsPageState extends State with SingleTickerPr
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
+ controller: _roomIdController,
onChanged: (value) {
- _renderParamsState.roomId = int.tryParse(value) ?? 0;
+ _renderParamsState.roomId = value;
},
),
const SizedBox(height: 16),
@@ -150,6 +159,7 @@ class _RenderParamsPageState extends State with SingleTickerPr
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
+ controller: _userIdController,
onChanged: (value) {
_renderParamsState.localUserId = value;
},
diff --git a/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_state.dart b/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_state.dart
index bb417ee..7c6c91b 100644
--- a/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/render_params/render_params_state.dart
@@ -10,7 +10,7 @@ class RenderParamsState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
UserListState? userListState;
// Local render parameters
@@ -53,7 +53,7 @@ class RenderParamsState extends ChangeNotifier {
}
void enterRoom() {
- if (localUserId == null || roomId == null) {
+ if (localUserId == null || roomId == null || roomId!.isEmpty) {
print("localUserId or roomId is null");
return;
}
@@ -62,7 +62,7 @@ class RenderParamsState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: localUserId!,
- roomId: roomId!,
+ strRoomId: roomId!,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_page.dart b/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_page.dart
index c6df01b..7deef87 100644
--- a/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_page.dart
@@ -5,6 +5,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import '../../../../common/user_list_widget.dart';
import '../../../../common/user_list_state.dart';
+import 'package:api_example/common/app_config.dart';
class ScreenshotPage extends StatefulWidget {
const ScreenshotPage({Key? key}) : super(key: key);
@@ -18,11 +19,17 @@ class _ScreenshotPageState extends State with SingleTickerProvid
late ScreenshotState _screenshotState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
_screenshotState = ScreenshotState();
+ _screenshotState.roomId = _roomIdController.text;
+ _screenshotState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -35,6 +42,8 @@ class _ScreenshotPageState extends State with SingleTickerProvid
void dispose() {
_tabController.dispose();
_screenshotState.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
_userListState?.dispose();
super.dispose();
}
@@ -136,9 +145,9 @@ class _ScreenshotPageState extends State with SingleTickerProvid
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
+ controller: _roomIdController,
onChanged: (value) {
- _screenshotState.roomId = int.tryParse(value) ?? 0;
+ _screenshotState.roomId = value;
},
),
const SizedBox(height: 16),
@@ -148,6 +157,7 @@ class _ScreenshotPageState extends State with SingleTickerProvid
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
+ controller: _userIdController,
onChanged: (value) {
_screenshotState.localUserId = value;
},
diff --git a/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_state.dart b/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_state.dart
index e2dc608..9ffb39c 100644
--- a/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/screenshot/screenshot_state.dart
@@ -13,7 +13,7 @@ class ScreenshotState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
UserListState? userListState;
ValueNotifier isEnterRoom = ValueNotifier(false);
@@ -52,7 +52,7 @@ class ScreenshotState extends ChangeNotifier {
}
void enterRoom() {
- if (localUserId == null || roomId == null) {
+ if (localUserId == null || roomId == null || roomId!.isEmpty) {
print("ScreenshotState localUserId or roomId is null");
Fluttertoast.showToast(msg: "localUserId or roomId is null");
return;
@@ -62,7 +62,7 @@ class ScreenshotState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: localUserId!,
- roomId: roomId!,
+ strRoomId: roomId!,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_page.dart b/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_page.dart
index 908f560..3829e9f 100644
--- a/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_page.dart
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import '../../../../common/user_list_widget.dart';
import '../../../../common/user_list_state.dart';
+import 'package:api_example/common/app_config.dart';
class SmallVideoStreamPage extends StatefulWidget {
const SmallVideoStreamPage({Key? key}) : super(key: key);
@@ -17,11 +18,17 @@ class _SmallVideoStreamPageState extends State with Single
late SmallVideoStreamState _smallVideoState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
_smallVideoState = SmallVideoStreamState();
+ _smallVideoState.roomId = _roomIdController.text;
+ _smallVideoState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -34,6 +41,8 @@ class _SmallVideoStreamPageState extends State with Single
void dispose() {
_tabController.dispose();
_smallVideoState.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
_userListState?.dispose();
super.dispose();
}
@@ -135,9 +144,9 @@ class _SmallVideoStreamPageState extends State with Single
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
+ controller: _roomIdController,
onChanged: (value) {
- _smallVideoState.roomId = int.tryParse(value) ?? 0;
+ _smallVideoState.roomId = value;
},
),
const SizedBox(height: 16),
@@ -147,6 +156,7 @@ class _SmallVideoStreamPageState extends State with Single
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
+ controller: _userIdController,
onChanged: (value) {
_smallVideoState.localUserId = value;
},
diff --git a/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_state.dart b/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_state.dart
index 2bffc4a..975dc86 100644
--- a/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/small_video_stream/small_video_stream_state.dart
@@ -12,7 +12,7 @@ class SmallVideoStreamState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
UserListState? userListState;
ValueNotifier isEnterRoom = ValueNotifier(false);
@@ -37,7 +37,7 @@ class SmallVideoStreamState extends ChangeNotifier {
}
void enterRoom() {
- if (localUserId == null || roomId == null) {
+ if (localUserId == null || roomId == null || roomId!.isEmpty) {
print("SmallVideoStreamState localUserId or roomId is null");
Fluttertoast.showToast(msg: "localUserId or roomId is null");
return;
@@ -47,7 +47,7 @@ class SmallVideoStreamState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: localUserId!,
- roomId: roomId!,
+ strRoomId: roomId!,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_page.dart b/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_page.dart
index 1178135..f4aaf70 100644
--- a/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_page.dart
@@ -5,6 +5,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import '../../../../common/user_list_widget.dart';
import '../../../../common/user_list_state.dart';
+import 'package:api_example/common/app_config.dart';
class VideoMuteImagePage extends StatefulWidget {
const VideoMuteImagePage({Key? key}) : super(key: key);
@@ -18,11 +19,17 @@ class _VideoMuteImagePageState extends State with SingleTick
late VideoMuteImageState _videoMuteState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
_videoMuteState = VideoMuteImageState();
+ _videoMuteState.roomId = _roomIdController.text;
+ _videoMuteState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -35,6 +42,8 @@ class _VideoMuteImagePageState extends State with SingleTick
void dispose() {
_tabController.dispose();
_videoMuteState.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
_userListState?.dispose();
super.dispose();
}
@@ -136,9 +145,9 @@ class _VideoMuteImagePageState extends State with SingleTick
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
+ controller: _roomIdController,
onChanged: (value) {
- _videoMuteState.roomId = int.tryParse(value) ?? 0;
+ _videoMuteState.roomId = value;
},
),
const SizedBox(height: 16),
@@ -148,6 +157,7 @@ class _VideoMuteImagePageState extends State with SingleTick
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
+ controller: _userIdController,
onChanged: (value) {
_videoMuteState.localUserId = value;
},
diff --git a/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_state.dart b/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_state.dart
index 1d2a257..97131f8 100644
--- a/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/video_mute_image/video_mute_image_state.dart
@@ -12,7 +12,7 @@ class VideoMuteImageState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
UserListState? userListState;
ValueNotifier isEnterRoom = ValueNotifier(false);
@@ -34,7 +34,7 @@ class VideoMuteImageState extends ChangeNotifier {
}
void enterRoom() {
- if (localUserId == null || roomId == null) {
+ if (localUserId == null || roomId == null || roomId!.isEmpty) {
print("VideoMuteImageState localUserId or roomId is null");
Fluttertoast.showToast(msg: "localUserId or roomId is null");
return;
@@ -44,7 +44,7 @@ class VideoMuteImageState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: localUserId!,
- roomId: roomId!,
+ strRoomId: roomId!,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_page.dart b/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_page.dart
index 7ff124b..c921937 100644
--- a/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_page.dart
@@ -5,6 +5,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'video_quality_state.dart';
import '../../../../common/user_list_widget.dart';
import '../../../../common/user_list_state.dart';
+import 'package:api_example/common/app_config.dart';
class VideoQualityPage extends StatefulWidget {
const VideoQualityPage({Key? key}) : super(key: key);
@@ -18,11 +19,17 @@ class _VideoQualityPageState extends State with SingleTickerPr
late VideoQualityState _videoQualityState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
_videoQualityState = VideoQualityState();
+ _videoQualityState.roomId = _roomIdController.text;
+ _videoQualityState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -36,6 +43,8 @@ class _VideoQualityPageState extends State with SingleTickerPr
_tabController.dispose();
_videoQualityState.dispose();
_userListState?.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
super.dispose();
}
@@ -140,9 +149,9 @@ class _VideoQualityPageState extends State with SingleTickerPr
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
+ controller: _roomIdController,
onChanged: (value) {
- state.roomId = int.tryParse(value) ?? 0;
+ state.roomId = value;
},
),
const SizedBox(height: 16),
@@ -152,6 +161,7 @@ class _VideoQualityPageState extends State with SingleTickerPr
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
+ controller: _userIdController,
onChanged: (value) {
state.localUserId = value;
},
diff --git a/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_state.dart b/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_state.dart
index 1d65bd8..086c1f3 100644
--- a/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_media/video_quality/video_quality_state.dart
@@ -14,7 +14,7 @@ class VideoQualityState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
List users = [];
UserListState? userListState;
@@ -46,7 +46,7 @@ class VideoQualityState extends ChangeNotifier {
}
}
- void enterRoom(String userId, int roomId) {
+ void enterRoom(String userId, String roomId) {
localUserId = userId;
this.roomId = roomId;
@@ -54,7 +54,7 @@ class VideoQualityState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(userId)
), TRTCAppScene.live);
diff --git a/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_page.dart b/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_page.dart
index e48f8c0..4d449b0 100644
--- a/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_page.dart
@@ -4,7 +4,7 @@ import 'ai_transcriber_state.dart';
class AITranscriberPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
final String sourceLanguage;
final List translationLanguages;
diff --git a/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_prepare_page.dart
index dc80481..5860ee6 100644
--- a/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'ai_transcriber_page.dart';
+import 'package:api_example/common/app_config.dart';
class AITranscriberPreparePage extends StatefulWidget {
const AITranscriberPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class AITranscriberPreparePage extends StatefulWidget {
}
class _AITranscriberPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
final _formKey = GlobalKey();
String _sourceLanguage = 'zh';
@@ -69,7 +70,6 @@ class _AITranscriberPreparePageState extends State {
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.meeting_room),
),
- keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter room ID';
@@ -137,12 +137,14 @@ class _AITranscriberPreparePageState extends State {
void _startTranscriber() {
if (_formKey.currentState!.validate()) {
+ AppConfig.roomId = _roomIdController.text;
+ AppConfig.userId = _userIdController.text;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AITranscriberPage(
userId: _userIdController.text,
- roomId: int.parse(_roomIdController.text),
+ roomId: _roomIdController.text,
sourceLanguage: _sourceLanguage,
translationLanguages: _selectedTranslationLanguages,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_state.dart b/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_state.dart
index ce4ee26..db14b1d 100644
--- a/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/ai_transcriber/ai_transcriber_state.dart
@@ -4,6 +4,7 @@ import 'package:tencent_rtc_sdk/ai_transcriber_manager.dart';
import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_listener.dart';
+import 'package:api_example/common/app_config.dart';
class AITranscriberState extends ChangeNotifier {
TRTCCloud? _trtcCloud;
@@ -12,7 +13,7 @@ class AITranscriberState extends ChangeNotifier {
AITranscriberListener? _transcriberListener;
String? _localUserId;
- int? _roomId;
+ String? _roomId;
bool _isEnterRoomSuccess = false;
bool _isTranscribing = false;
bool _isPaused = false;
@@ -20,14 +21,14 @@ class AITranscriberState extends ChangeNotifier {
final List _transcripts = [];
String? get localUserId => _localUserId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
bool get isEnterRoomSuccess => _isEnterRoomSuccess;
bool get isTranscribing => _isTranscribing;
bool get isPaused => _isPaused;
String get statusMessage => _statusMessage;
List get transcripts => List.unmodifiable(_transcripts);
- Future initialize({required String userId, required int roomId}) async {
+ Future initialize({required String userId, required String roomId}) async {
_localUserId = userId;
_roomId = roomId;
_statusMessage = 'Initializing...';
@@ -70,11 +71,12 @@ class AITranscriberState extends ChangeNotifier {
);
_trtcCloud?.registerListener(_listener!);
+ final roomIdStr = _roomId ?? AppConfig.defaultRoomId;
_trtcCloud?.enterRoom(
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomIdStr,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(userId),
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_page.dart b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_page.dart
index 59fb2d5..39b672e 100644
--- a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_page.dart
@@ -22,12 +22,12 @@ class _MusicEffectPageState extends State {
@override
void initState() {
super.initState();
- _state = MusicEffectState(widget.userId, int.tryParse(widget.roomId) ?? 0);
+ _state = MusicEffectState(widget.userId, widget.roomId);
_initRoom();
}
Future _initRoom() async {
- await _state.enterRoom(widget.userId, int.tryParse(widget.roomId) ?? 0);
+ await _state.enterRoom(widget.userId, widget.roomId);
setState(() {
_isInit = true;
});
diff --git a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_prepare_page.dart
index 97bdc45..ead26c8 100644
--- a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'music_effect_page.dart';
+import 'package:api_example/common/app_config.dart';
class MusicEffectPreparePage extends StatefulWidget {
const MusicEffectPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class MusicEffectPreparePage extends StatefulWidget {
}
class _MusicEffectPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
String? _error;
void _onEnter() {
@@ -22,6 +23,8 @@ class _MusicEffectPreparePageState extends State {
});
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
@@ -43,7 +46,7 @@ class _MusicEffectPreparePageState extends State {
TextField(controller: _userIdController),
const SizedBox(height: 16),
const Text('Room ID'),
- TextField(controller: _roomIdController, keyboardType: TextInputType.number),
+ TextField(controller: _roomIdController),
const SizedBox(height: 32),
if (_error != null) ...[
Text(_error!, style: const TextStyle(color: Colors.red)),
diff --git a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_state.dart b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_state.dart
index b2fba2a..3e7584e 100644
--- a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/music_effect/music_effect_state.dart
@@ -14,7 +14,7 @@ class MusicEffectState extends ChangeNotifier {
UserListState? userListState;
String? _userId;
- int? _roomId;
+ String? _roomId;
bool _isEnterRoom = false;
bool _isInit = false;
@@ -37,14 +37,14 @@ class MusicEffectState extends ChangeNotifier {
bool get isInit => _isInit;
bool get isEntered => _isEnterRoom;
String? get userId => _userId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
- MusicEffectState(String userId, int roomId) {
+ MusicEffectState(String userId, String roomId) {
_userId = userId;
_roomId = roomId;
}
- Future enterRoom(String userId, int roomId) async {
+ Future enterRoom(String userId, String roomId) async {
_userId = userId;
_roomId = roomId;
_trtcCloud = await TRTCCloud.sharedInstance();
@@ -57,7 +57,7 @@ class MusicEffectState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
userSig: GenerateTestUserSig.genTestSig(userId),
role: TRTCRoleType.anchor,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_page.dart b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_page.dart
index 9c2d3d0..a8a2648 100644
--- a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_page.dart
@@ -24,7 +24,7 @@ class _VoiceEffectPageState extends State {
}
Future _initRoom() async {
- await _state.enterRoom(widget.userId, int.tryParse(widget.roomId) ?? 0);
+ await _state.enterRoom(widget.userId, widget.roomId);
setState(() {
_isInit = true;
});
diff --git a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_prepare_page.dart
index 3951ba8..de29948 100644
--- a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'voice_effect_page.dart';
+import 'package:api_example/common/app_config.dart';
class VoiceEffectPreparePage extends StatefulWidget {
const VoiceEffectPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class VoiceEffectPreparePage extends StatefulWidget {
}
class _VoiceEffectPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
String? _error;
void _onEnter() {
@@ -22,6 +23,8 @@ class _VoiceEffectPreparePageState extends State {
});
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
@@ -43,7 +46,7 @@ class _VoiceEffectPreparePageState extends State {
TextField(controller: _userIdController),
const SizedBox(height: 16),
const Text('Room ID'),
- TextField(controller: _roomIdController, keyboardType: TextInputType.number),
+ TextField(controller: _roomIdController),
const SizedBox(height: 32),
if (_error != null) ...[
Text(_error!, style: const TextStyle(color: Colors.red)),
diff --git a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_state.dart b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_state.dart
index 981f6cd..1a4c890 100644
--- a/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/audio_effect_manager/voice_effect/voice_effect_state.dart
@@ -13,14 +13,14 @@ class VoiceEffectState extends ChangeNotifier {
UserListState? userListState;
String? _userId;
- int? _roomId;
+ String? _roomId;
bool _isEnterRoom = false;
bool _isInit = false;
bool get isInit => _isInit;
bool get isEntered => _isEnterRoom;
String? get userId => _userId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
bool earMonitorEnabled = false;
int earMonitorVolume = 100;
@@ -35,7 +35,7 @@ class VoiceEffectState extends ChangeNotifier {
TXAudioEffectManager? _audioEffectManager;
- Future enterRoom(String userId, int roomId) async {
+ Future enterRoom(String userId, String roomId) async {
_userId = userId;
_roomId = roomId;
_trtcCloud = await TRTCCloud.sharedInstance();
@@ -48,7 +48,7 @@ class VoiceEffectState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
userSig: GenerateTestUserSig.genTestSig(userId),
role: TRTCRoleType.anchor,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_page.dart b/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_page.dart
index c90a202..990dc37 100644
--- a/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_page.dart
@@ -5,7 +5,7 @@ import 'package:api_example/common/user_list_widget.dart';
class ConnectOtherRoomPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const ConnectOtherRoomPage({Key? key, required this.userId, required this.roomId}) : super(key: key);
@override
@@ -83,7 +83,6 @@ class _ConnectOtherRoomPageState extends State {
labelText: 'Target Room ID',
border: OutlineInputBorder(),
),
- keyboardType: TextInputType.number,
),
const SizedBox(height: 12),
TextField(
@@ -99,9 +98,9 @@ class _ConnectOtherRoomPageState extends State {
Expanded(
child: ElevatedButton(
onPressed: () {
- final targetRoomId = int.tryParse(_targetRoomIdController.text.trim());
+ final targetRoomId = _targetRoomIdController.text.trim();
final targetUserId = _targetUserIdController.text.trim();
- if (targetRoomId != null && targetUserId.isNotEmpty) {
+ if (targetRoomId.isNotEmpty && targetUserId.isNotEmpty) {
state.connectOtherRoom(targetRoomId, targetUserId);
}
},
diff --git a/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_prepare_page.dart
index 1a6dcd5..4677541 100644
--- a/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/connect_other_room/connect_other_room_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'connect_other_room_page.dart';
+import 'package:api_example/common/app_config.dart';
class ConnectOtherRoomPreparePage extends StatefulWidget {
const ConnectOtherRoomPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class ConnectOtherRoomPreparePage extends StatefulWidget {
}
class _ConnectOtherRoomPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
Widget build(BuildContext context) {
@@ -35,7 +36,6 @@ class _ConnectOtherRoomPreparePageState extends State _userId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
String get statusMessage => _statusMessage;
bool get isEnterRoom => _isEnterRoom;
bool get isConnecting => _isConnecting;
bool get isConnected => _isConnected;
String? get targetUserId => _targetUserId;
- int? get targetRoomId => _targetRoomId;
+ String? get targetRoomId => _targetRoomId;
- Future enterRoom(String userId, int roomId) async {
+ Future enterRoom(String userId, String roomId) async {
_userId = userId;
_roomId = roomId;
_statusMessage = 'Entering room...';
@@ -44,7 +44,7 @@ class ConnectOtherRoomState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
userSig: GenerateTestUserSig.genTestSig(userId),
role: TRTCRoleType.anchor,
),
@@ -53,7 +53,7 @@ class ConnectOtherRoomState extends ChangeNotifier {
_trtcCloud?.startLocalAudio(TRTCAudioQuality.defaultMode);
}
- void connectOtherRoom(int targetRoomId, String targetUserId) {
+ void connectOtherRoom(String targetRoomId, String targetUserId) {
if (_trtcCloud == null) return;
_isConnecting = true;
_statusMessage = 'Connecting to other room...';
diff --git a/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_page.dart b/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_page.dart
index d18beb1..ef62f0d 100644
--- a/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_page.dart
@@ -4,7 +4,7 @@ import 'custom_audio_capture_state.dart';
class CustomAudioCapturePage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const CustomAudioCapturePage({
Key? key,
diff --git a/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_prepare_page.dart
index 49897a6..514a2aa 100644
--- a/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'custom_audio_capture_page.dart';
+import 'package:api_example/common/app_config.dart';
class CustomAudioCapturePreparePage extends StatefulWidget {
const CustomAudioCapturePreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class CustomAudioCapturePreparePage extends StatefulWidget {
}
class _CustomAudioCapturePreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
final _formKey = GlobalKey();
@override
@@ -144,14 +145,10 @@ class _CustomAudioCapturePreparePageState extends State CustomAudioCapturePage(
userId: _userIdController.text,
- roomId: int.parse(_roomIdController.text),
+ roomId: _roomIdController.text,
),
),
);
diff --git a/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_state.dart b/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_state.dart
index 7b538c4..32df618 100644
--- a/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/custom_audio_capture/custom_audio_capture_state.dart
@@ -5,11 +5,12 @@ import 'package:flutter/foundation.dart';
import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_listener.dart';
+import 'package:api_example/common/app_config.dart';
class CustomAudioCaptureState extends ChangeNotifier {
bool _isCustomAudioEnabled = false;
String? _localUserId;
- int? _roomId;
+ String? _roomId;
TRTCCloud? _trtcCloud;
bool _isInitialized = false;
final Map _remoteUsers = {};
@@ -52,7 +53,7 @@ class CustomAudioCaptureState extends ChangeNotifier {
// Getters
bool get isCustomAudioEnabled => _isCustomAudioEnabled;
String? get localUserId => _localUserId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
List get remoteUsers => _remoteUsers.values.toList();
bool get isInitialized => _isInitialized;
String get statusMessage => _statusMessage;
@@ -63,7 +64,7 @@ class CustomAudioCaptureState extends ChangeNotifier {
Future initialize({
required String userId,
- required int roomId,
+ required String roomId,
}) async {
_localUserId = userId;
_roomId = roomId;
@@ -84,11 +85,12 @@ class CustomAudioCaptureState extends ChangeNotifier {
}
_statusMessage = 'Entering room...';
+ final roomIdStr = _roomId ?? AppConfig.defaultRoomId;
_trtcCloud?.enterRoom(
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: _localUserId ?? "",
- roomId: roomId ?? 123456,
+ strRoomId: roomIdStr,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(_localUserId!),
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message.dart b/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message.dart
index fe7e802..7355239 100644
--- a/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message.dart
@@ -5,7 +5,7 @@ import 'package:api_example/common/user_list_widget.dart';
class CustomMessagePage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const CustomMessagePage({Key? key, required this.userId, required this.roomId}) : super(key: key);
@override
diff --git a/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_prepare_page.dart
index 595d9df..03a58cb 100644
--- a/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'custom_message.dart';
+import 'package:api_example/common/app_config.dart';
class CustomMessagePreparePage extends StatefulWidget {
const CustomMessagePreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class CustomMessagePreparePage extends StatefulWidget {
}
class _CustomMessagePreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
Widget build(BuildContext context) {
@@ -35,7 +36,6 @@ class _CustomMessagePreparePageState extends State {
labelText: 'Room ID',
border: OutlineInputBorder(),
),
- keyboardType: TextInputType.number,
),
const Spacer(),
ElevatedButton(
@@ -50,13 +50,15 @@ class _CustomMessagePreparePageState extends State {
void _onEnterRoom() {
final userId = _userIdController.text.trim();
- final roomId = int.tryParse(_roomIdController.text.trim());
- if (userId.isEmpty || roomId == null) {
+ final roomId = _roomIdController.text.trim();
+ if (userId.isEmpty || roomId.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Please enter User ID and Room ID')),
);
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
diff --git a/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_state.dart b/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_state.dart
index 85a9835..95226ed 100644
--- a/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/custom_message/custom_message_state.dart
@@ -11,7 +11,7 @@ class CustomMessageState extends ChangeNotifier {
TRTCCloudListener? _listener;
String? _userId;
- int? _roomId;
+ String? _roomId;
String _statusMessage = 'Not in room';
bool _isEnterRoom = false;
@@ -21,11 +21,11 @@ class CustomMessageState extends ChangeNotifier {
List get messages => List.unmodifiable(_messages);
String? get userId => _userId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
String get statusMessage => _statusMessage;
bool get isEnterRoom => _isEnterRoom;
- Future enterRoom(String userId, int roomId) async {
+ Future enterRoom(String userId, String roomId) async {
_userId = userId;
_roomId = roomId;
_statusMessage = 'Entering room...';
@@ -39,7 +39,7 @@ class CustomMessageState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
userSig: GenerateTestUserSig.genTestSig(userId),
role: TRTCRoleType.anchor,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_page.dart b/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_page.dart
index c34d4c6..a71defb 100644
--- a/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_page.dart
@@ -7,6 +7,7 @@ import 'package:tencent_rtc_sdk/tx_device_manager.dart';
import '../../../common/user_list_widget.dart';
import '../../../common/user_list_state.dart';
import 'device_manager_state.dart';
+import 'package:api_example/common/app_config.dart';
class DeviceManagerPage extends StatefulWidget {
const DeviceManagerPage({Key? key}) : super(key: key);
@@ -20,11 +21,18 @@ class _DeviceManagerPageState extends State with SingleTicker
late DeviceManagerState _deviceManagerState;
UserListState? _userListState;
+ final _roomIdController = TextEditingController(
+ text: AppConfig.roomId);
+ final _userIdController = TextEditingController(
+ text: AppConfig.userId);
+
@override
void initState() {
super.initState();
_tabController = TabController(length: 2, vsync: this);
_deviceManagerState = DeviceManagerState();
+ _deviceManagerState.roomId = _roomIdController.text;
+ _deviceManagerState.localUserId = _userIdController.text;
}
Future _initialize() async {
@@ -39,6 +47,8 @@ class _DeviceManagerPageState extends State with SingleTicker
_tabController.dispose();
_deviceManagerState.dispose();
_userListState?.dispose();
+ _roomIdController.dispose();
+ _userIdController.dispose();
super.dispose();
}
@@ -134,18 +144,19 @@ class _DeviceManagerPageState extends State with SingleTicker
mainAxisSize: MainAxisSize.min,
children: [
TextField(
+ controller: _roomIdController,
decoration: const InputDecoration(
labelText: 'Room ID',
border: OutlineInputBorder(),
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 12),
),
- keyboardType: TextInputType.number,
onChanged: (value) {
- _deviceManagerState.roomId = int.tryParse(value) ?? 0;
+ _deviceManagerState.roomId = value;
},
),
const SizedBox(height: 16),
TextField(
+ controller: _userIdController,
decoration: const InputDecoration(
labelText: 'User ID',
border: OutlineInputBorder(),
@@ -166,7 +177,8 @@ class _DeviceManagerPageState extends State with SingleTicker
if (isEnterRoom) {
_deviceManagerState.exitRoom();
} else {
- if (_deviceManagerState.localUserId != null && _deviceManagerState.roomId != null) {
+ if (_deviceManagerState.localUserId != null && _deviceManagerState.localUserId!.isNotEmpty
+ && _deviceManagerState.roomId != null && _deviceManagerState.roomId!.isNotEmpty) {
_deviceManagerState.enterRoom();
}
}
diff --git a/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_state.dart b/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_state.dart
index 22ac249..2d1d918 100644
--- a/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/device_manager/device_manager_state.dart
@@ -13,7 +13,7 @@ class DeviceManagerState extends ChangeNotifier {
bool _isInitialized = false;
String? localUserId;
- int? roomId;
+ String? roomId;
UserListState? userListState;
double focusPositionX = 0.5;
@@ -43,7 +43,7 @@ class DeviceManagerState extends ChangeNotifier {
}
void enterRoom() {
- if (localUserId == null || roomId == null) {
+ if (localUserId == null || roomId == null || localUserId!.isEmpty || roomId!.isEmpty) {
print("DeviceManagerState localUserId or roomId is null");
Fluttertoast.showToast(msg: "localUserId or roomId is null");
return;
@@ -53,7 +53,7 @@ class DeviceManagerState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: localUserId!,
- roomId: roomId!,
+ strRoomId: roomId!,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/advance_more/network_speed_test/network_speed_test_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/network_speed_test/network_speed_test_prepare_page.dart
index b1e18c9..bcf3e18 100644
--- a/TRTC-API-Example/lib/pages/advance_more/network_speed_test/network_speed_test_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/network_speed_test/network_speed_test_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'network_speed_test_page.dart';
+import 'package:api_example/common/app_config.dart';
class NetworkSpeedTestPreparePage extends StatefulWidget {
const NetworkSpeedTestPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class NetworkSpeedTestPreparePage extends StatefulWidget {
}
class _NetworkSpeedTestPreparePageState extends State {
- final TextEditingController _roomIdController = TextEditingController();
- final TextEditingController _userIdController = TextEditingController();
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
@override
void dispose() {
@@ -22,6 +23,8 @@ class _NetworkSpeedTestPreparePageState extends State {
}
Future _initRoom() async {
- await _state.enterRoom(widget.userId, int.tryParse(widget.roomId) ?? 0);
+ await _state.enterRoom(widget.userId, widget.roomId);
setState(() {
_isInit = true;
});
diff --git a/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_prepare_page.dart
index b22b804..6514978 100644
--- a/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'screen_share_page.dart';
+import 'package:api_example/common/app_config.dart';
class ScreenSharePreparePage extends StatefulWidget {
const ScreenSharePreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class ScreenSharePreparePage extends StatefulWidget {
}
class _ScreenSharePreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
String? _error;
void _onEnter() {
@@ -22,6 +23,8 @@ class _ScreenSharePreparePageState extends State {
});
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
@@ -43,7 +46,7 @@ class _ScreenSharePreparePageState extends State {
TextField(controller: _userIdController),
const SizedBox(height: 16),
const Text('Room ID'),
- TextField(controller: _roomIdController, keyboardType: TextInputType.number),
+ TextField(controller: _roomIdController),
const SizedBox(height: 32),
if (_error != null) ...[
Text(_error!, style: const TextStyle(color: Colors.red)),
diff --git a/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_state.dart b/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_state.dart
index 9abf76e..966d698 100644
--- a/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/screen_share/screen_share_state.dart
@@ -11,7 +11,7 @@ class ScreenShareState extends ChangeNotifier {
UserListState? userListState;
String? _userId;
- int? _roomId;
+ String? _roomId;
bool _isEnterRoom = false;
bool _isInit = false;
List logs = [];
@@ -19,9 +19,9 @@ class ScreenShareState extends ChangeNotifier {
bool get isInit => _isInit;
bool get isEntered => _isEnterRoom;
String? get userId => _userId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
- Future enterRoom(String userId, int roomId) async {
+ Future enterRoom(String userId, String roomId) async {
_userId = userId;
_roomId = roomId;
_trtcCloud = await TRTCCloud.sharedInstance();
@@ -33,7 +33,7 @@ class ScreenShareState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
userSig: GenerateTestUserSig.genTestSig(userId),
role: TRTCRoleType.anchor,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_page.dart b/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_page.dart
index 7547ce5..f655992 100644
--- a/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_page.dart
@@ -68,11 +68,12 @@ class _SetBeautyStylePageState extends State {
}
void _enterRoom() {
+ final roomIdStr = widget.roomId;
_trtcCloud?.enterRoom(
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: widget.userId,
- roomId: int.tryParse(widget.roomId) ?? 0,
+ strRoomId: roomIdStr,
userSig: GenerateTestUserSig.genTestSig(widget.userId),
role: TRTCRoleType.anchor,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_prepare_page.dart
index e9de48b..77eb144 100644
--- a/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/set_beauty_style/set_beauty_style_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'set_beauty_style_page.dart';
+import 'package:api_example/common/app_config.dart';
class SetBeautyStylePreparePage extends StatefulWidget {
const SetBeautyStylePreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class SetBeautyStylePreparePage extends StatefulWidget {
}
class _SetBeautyStylePreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
void dispose() {
@@ -22,6 +23,8 @@ class _SetBeautyStylePreparePageState extends State {
void _onEnter() {
final userId = _userIdController.text;
final roomId = _roomIdController.text;
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
diff --git a/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_page.dart b/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_page.dart
index 9371c02..24a63b8 100644
--- a/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_page.dart
@@ -70,11 +70,12 @@ class _SetWatermarkPageState extends State {
}
void _enterRoom() {
+ final roomIdStr = widget.roomId;
_trtcCloud?.enterRoom(
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: widget.userId,
- roomId: int.tryParse(widget.roomId) ?? 0,
+ strRoomId: roomIdStr,
userSig: GenerateTestUserSig.genTestSig(widget.userId),
role: TRTCRoleType.anchor,
),
diff --git a/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_prepare_page.dart
index 5e9c8ff..f6ec9f5 100644
--- a/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/set_watermark/set_watermark_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'set_watermark_page.dart';
+import 'package:api_example/common/app_config.dart';
class SetWatermarkPreparePage extends StatefulWidget {
const SetWatermarkPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class SetWatermarkPreparePage extends StatefulWidget {
}
class _SetWatermarkPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
void dispose() {
@@ -22,6 +23,8 @@ class _SetWatermarkPreparePageState extends State {
void _onEnter() {
final userId = _userIdController.text;
final roomId = _roomIdController.text;
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
diff --git a/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_page.dart b/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_page.dart
index b0655d1..91b0b0e 100644
--- a/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_page.dart
@@ -5,7 +5,7 @@ import 'package:api_example/common/user_list_widget.dart';
class SwitchRoomPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const SwitchRoomPage({Key? key, required this.userId, required this.roomId}) : super(key: key);
@override
@@ -88,15 +88,14 @@ class _SwitchRoomPageState extends State {
labelText: 'Target Room ID',
border: OutlineInputBorder(),
),
- keyboardType: TextInputType.number,
),
),
const SizedBox(width: 8),
ElevatedButton(
onPressed: () {
FocusScope.of(context).unfocus();
- final newRoomId = int.tryParse(_switchRoomIdController.text.trim());
- if (newRoomId != null) {
+ final newRoomId = _switchRoomIdController.text.trim();
+ if (newRoomId.isNotEmpty) {
state.switchRoom(newRoomId);
}
},
diff --git a/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_prepare_page.dart b/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_prepare_page.dart
index c6bc45f..4cff743 100644
--- a/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'switch_room_page.dart';
+import 'package:api_example/common/app_config.dart';
class SwitchRoomPreparePage extends StatefulWidget {
const SwitchRoomPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class SwitchRoomPreparePage extends StatefulWidget {
}
class _SwitchRoomPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
Widget build(BuildContext context) {
@@ -35,7 +36,6 @@ class _SwitchRoomPreparePageState extends State {
labelText: 'Room ID',
border: OutlineInputBorder(),
),
- keyboardType: TextInputType.number,
),
const Spacer(),
ElevatedButton(
@@ -50,13 +50,15 @@ class _SwitchRoomPreparePageState extends State {
void _onEnterRoom() {
final userId = _userIdController.text.trim();
- final roomId = int.tryParse(_roomIdController.text.trim());
- if (userId.isEmpty || roomId == null) {
+ final roomId = _roomIdController.text.trim();
+ if (userId.isEmpty || roomId.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Please enter User ID and Room ID')),
);
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
diff --git a/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_state.dart b/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_state.dart
index 4770e99..8efe22b 100644
--- a/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_state.dart
+++ b/TRTC-API-Example/lib/pages/advance_more/switch_room/switch_room_state.dart
@@ -10,21 +10,21 @@ class SwitchRoomState extends ChangeNotifier {
TRTCCloudListener? _listener;
String? _userId;
- int? _roomId;
+ String? _roomId;
String _statusMessage = 'Not in room';
bool _isEnterRoom = false;
bool _isSwitching = false;
- int? _pendingRoomId; // 用于切换房间时暂存目标房间号
+ String? _pendingRoomId; // 用于切换房间时暂存目标房间号
UserListState? userListState;
String? get userId => _userId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
String get statusMessage => _statusMessage;
bool get isEnterRoom => _isEnterRoom;
bool get isSwitching => _isSwitching;
- Future enterRoom(String userId, int roomId) async {
+ Future enterRoom(String userId, String roomId) async {
_userId = userId;
_roomId = roomId;
_statusMessage = 'Entering room...';
@@ -38,7 +38,7 @@ class SwitchRoomState extends ChangeNotifier {
TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: userId,
- roomId: roomId,
+ strRoomId: roomId,
userSig: GenerateTestUserSig.genTestSig(userId),
role: TRTCRoleType.anchor,
),
@@ -47,7 +47,7 @@ class SwitchRoomState extends ChangeNotifier {
_trtcCloud?.startLocalAudio(TRTCAudioQuality.defaultMode);
}
- void switchRoom(int newRoomId) {
+ void switchRoom(String newRoomId) {
if (_trtcCloud == null || _userId == null) return;
_isSwitching = true;
_statusMessage = 'Switching room...';
@@ -55,7 +55,7 @@ class SwitchRoomState extends ChangeNotifier {
notifyListeners();
final config = TRTCSwitchRoomConfig(
userSig: GenerateTestUserSig.genTestSig(_userId!),
- roomId: newRoomId,
+ strRoomId: newRoomId,
);
_trtcCloud?.switchRoom(config);
}
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_page.dart
index 310bec8..fabef97 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_page.dart
@@ -4,7 +4,7 @@ import 'audio_call_state.dart';
class AudioCallPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const AudioCallPage({
Key? key,
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_prepare_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_prepare_page.dart
index 49ae949..b2c73bd 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'audio_call_page.dart';
+import 'package:api_example/common/app_config.dart';
class AudioCallPreparePage extends StatefulWidget {
const AudioCallPreparePage({Key? key}) : super(key: key);
@@ -10,8 +11,8 @@ class AudioCallPreparePage extends StatefulWidget {
class _AudioCallPreparePageState extends State {
- final TextEditingController _userIdController = TextEditingController();
- final TextEditingController _roomIdController = TextEditingController();
+ final TextEditingController _userIdController = TextEditingController(text: AppConfig.userId);
+ final TextEditingController _roomIdController = TextEditingController(text: AppConfig.roomId);
final _formKey = GlobalKey();
@override
@@ -58,7 +59,6 @@ class _AudioCallPreparePageState extends State {
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.meeting_room),
),
- keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter room ID';
@@ -101,12 +101,14 @@ class _AudioCallPreparePageState extends State {
void _startCall() {
if (_formKey.currentState!.validate()) {
+ AppConfig.roomId = _roomIdController.text;
+ AppConfig.userId = _userIdController.text;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AudioCallPage(
userId: _userIdController.text,
- roomId: int.parse(_roomIdController.text),
+ roomId: _roomIdController.text,
),
),
);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_state.dart b/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_state.dart
index 96b5fdc..ee2c223 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_state.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/audio_call/audio_call_state.dart
@@ -4,12 +4,13 @@ import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_listener.dart';
import 'package:tencent_rtc_sdk/tx_device_manager.dart';
+import 'package:api_example/common/app_config.dart';
class AudioCallState extends ChangeNotifier {
bool _isLocalMicrophoneEnabled = true;
bool _isLocalSpeakerEnabled = true;
String? _localUserId;
- int? _roomId;
+ String? _roomId;
bool _isCallActive = false;
TRTCCloud? _trtcCloud;
TXDeviceManager? _deviceManager;
@@ -22,7 +23,7 @@ class AudioCallState extends ChangeNotifier {
bool get isLocalMicrophoneEnabled => _isLocalMicrophoneEnabled;
bool get isLocalSpeakerEnabled => _isLocalSpeakerEnabled;
String? get localUserId => _localUserId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
bool get isCallActive => _isCallActive;
List get remoteUsers => _remoteUsers.values.toList();
bool get isInitialized => _isInitialized;
@@ -33,7 +34,7 @@ class AudioCallState extends ChangeNotifier {
Future initializeCall({
required String userId,
- required int roomId,
+ required String roomId,
}) async {
_localUserId = userId;
_roomId = roomId;
@@ -56,10 +57,11 @@ class AudioCallState extends ChangeNotifier {
}
_statusMessage = 'Entering room...';
+ final roomIdStr = _roomId ?? AppConfig.defaultRoomId;
_trtcCloud?.enterRoom(TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: _localUserId ?? "",
- roomId: roomId ?? 123456,
+ strRoomId: roomIdStr,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(_localUserId!)
), TRTCAppScene.audioCall);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_page.dart
index 7a52d88..cf5889d 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_page.dart
@@ -5,7 +5,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud_video_view.dart';
class LiveRoomPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const LiveRoomPage({
Key? key,
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_prepare_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_prepare_page.dart
index 70c044f..57134d2 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'live_room_page.dart';
+import 'package:api_example/common/app_config.dart';
class LiveRoomPreparePage extends StatefulWidget {
const LiveRoomPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class LiveRoomPreparePage extends StatefulWidget {
}
class _LiveRoomPreparePageState extends State {
- final _userIdController = TextEditingController();
- final _roomIdController = TextEditingController();
+ final _userIdController = TextEditingController(text: AppConfig.userId);
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
void dispose() {
@@ -44,7 +45,7 @@ class _LiveRoomPreparePageState extends State {
labelText: 'Room ID',
border: OutlineInputBorder(),
),
- keyboardType: TextInputType.number,
+ keyboardType: TextInputType.text,
),
const SizedBox(height: 20),
const Spacer(),
@@ -72,12 +73,14 @@ class _LiveRoomPreparePageState extends State {
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => LiveRoomPage(
userId: userId,
- roomId: int.parse(roomId),
+ roomId: roomId,
),
),
);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_state.dart b/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_state.dart
index 7717599..1e323ed 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_state.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/live_room/live_room_state.dart
@@ -8,6 +8,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_listener.dart';
import 'package:tencent_rtc_sdk/tx_device_manager.dart';
import 'package:api_example/utils/bidirectional_map.dart';
+import 'package:api_example/common/app_config.dart';
class RemoteUserState {
final String userId;
@@ -116,7 +117,7 @@ class LiveRoomState extends ChangeNotifier {
bool _isLocalMicrophoneEnabled = false;
String? _localUserId;
int? _localViewKey;
- int? _roomId;
+ String? _roomId;
bool _isCallActive = false;
TRTCCloud? _trtcCloud;
TXDeviceManager? _deviceManager;
@@ -133,7 +134,7 @@ class LiveRoomState extends ChangeNotifier {
bool get isLocalCameraEnabled => _isLocalCameraEnabled;
bool get isLocalMicrophoneEnabled => _isLocalMicrophoneEnabled;
String? get localUserId => _localUserId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
bool get isCallActive => _isCallActive;
List get remoteUsers => _remoteUsers.values.toList();
bool get isInitialized => _isInitialized;
@@ -148,7 +149,7 @@ class LiveRoomState extends ChangeNotifier {
Future initializeRoom({
required String userId,
- required int roomId,
+ required String roomId,
}) async {
_localUserId = userId;
_roomId = roomId;
@@ -171,10 +172,11 @@ class LiveRoomState extends ChangeNotifier {
}
_statusMessage = 'Entering room...';
+ final roomIdStr = _roomId ?? AppConfig.defaultRoomId;
_trtcCloud?.enterRoom(TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: _localUserId ?? "",
- roomId: _roomId ?? 123456,
+ strRoomId: roomIdStr,
role: _isAnchor ? TRTCRoleType.anchor : TRTCRoleType.audience,
userSig: GenerateTestUserSig.genTestSig(_localUserId!)
), TRTCAppScene.live);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_page.dart
index a51f28b..7592a05 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_page.dart
@@ -6,7 +6,7 @@ import 'video_call_state.dart';
class VideoCallPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const VideoCallPage({
Key? key,
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_prepare_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_prepare_page.dart
index 23d6a5b..e742d3d 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_prepare_page.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'video_call_page.dart';
+import 'package:api_example/common/app_config.dart';
class VideoCallPreparePage extends StatefulWidget {
const VideoCallPreparePage({Key? key}) : super(key: key);
@@ -10,8 +11,8 @@ class VideoCallPreparePage extends StatefulWidget {
}
class _VideoCallPreparePageState extends State {
- final _userIdController = TextEditingController();
- final _roomIdController = TextEditingController();
+ final _userIdController = TextEditingController(text: AppConfig.userId);
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
final _formKey = GlobalKey();
bool _sdkReady = false;
@@ -68,7 +69,6 @@ class _VideoCallPreparePageState extends State {
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.meeting_room),
),
- keyboardType: TextInputType.number,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Please enter room ID';
@@ -94,12 +94,14 @@ class _VideoCallPreparePageState extends State {
void _startCall() {
if (_formKey.currentState!.validate()) {
+ AppConfig.roomId = _roomIdController.text;
+ AppConfig.userId = _userIdController.text;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VideoCallPage(
userId: _userIdController.text,
- roomId: int.parse(_roomIdController.text),
+ roomId: _roomIdController.text,
),
),
);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_state.dart b/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_state.dart
index 5d11230..606b9fa 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_state.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/video_call/video_call_state.dart
@@ -4,6 +4,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_listener.dart';
import 'package:tencent_rtc_sdk/tx_device_manager.dart';
+import 'package:api_example/common/app_config.dart';
class VideoCallState extends ChangeNotifier {
bool _isLocalCameraMute = false;
@@ -11,7 +12,7 @@ class VideoCallState extends ChangeNotifier {
bool _isMuteAllRemoteVideo = false;
bool _isMuteAllRemoteAudio = false;
String? _localUserId;
- int? _roomId;
+ String? _roomId;
int _localViewId = 0;
bool _isCallActive = false;
TRTCCloud? _trtcCloud;
@@ -27,7 +28,7 @@ class VideoCallState extends ChangeNotifier {
bool get isMuteAllRemoteVideo => _isMuteAllRemoteVideo;
bool get isMuteAllRemoteAudio => _isMuteAllRemoteAudio;
String? get localUserId => _localUserId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
int get localViewId => _localViewId;
bool get isCallActive => _isCallActive;
List get remoteUsers => _remoteUsers.values.toList();
@@ -39,7 +40,7 @@ class VideoCallState extends ChangeNotifier {
Future initializeCall({
required String userId,
- required int roomId,
+ required String roomId,
}) async {
_localUserId = userId;
_roomId = roomId;
@@ -63,10 +64,11 @@ class VideoCallState extends ChangeNotifier {
}
_statusMessage = 'Entering room...';
+ final roomIdStr = _roomId ?? AppConfig.defaultRoomId;
_trtcCloud?.enterRoom(TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: _localUserId ?? "",
- roomId: roomId ?? 123456,
+ strRoomId: roomIdStr,
role: TRTCRoleType.anchor,
userSig: GenerateTestUserSig.genTestSig(_localUserId!)
), TRTCAppScene.videoCall);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_page.dart
index cce3aaf..f2aba9d 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_page.dart
@@ -4,7 +4,7 @@ import 'voice_room_state.dart';
class VoiceRoomPage extends StatefulWidget {
final String userId;
- final int roomId;
+ final String roomId;
const VoiceRoomPage({
Key? key,
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_prepare_page.dart b/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_prepare_page.dart
index 0a412ef..2410adb 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_prepare_page.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_prepare_page.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'voice_room_page.dart';
+import 'package:api_example/common/app_config.dart';
class VoiceRoomPreparePage extends StatefulWidget {
const VoiceRoomPreparePage({Key? key}) : super(key: key);
@@ -9,8 +10,8 @@ class VoiceRoomPreparePage extends StatefulWidget {
}
class _VoiceRoomPreparePageState extends State {
- final _userIdController = TextEditingController();
- final _roomIdController = TextEditingController();
+ final _userIdController = TextEditingController(text: AppConfig.userId);
+ final _roomIdController = TextEditingController(text: AppConfig.roomId);
@override
void dispose() {
@@ -44,7 +45,7 @@ class _VoiceRoomPreparePageState extends State {
labelText: 'Room ID',
border: OutlineInputBorder(),
),
- keyboardType: TextInputType.number,
+ keyboardType: TextInputType.text,
),
const Spacer(),
ElevatedButton(
@@ -71,12 +72,14 @@ class _VoiceRoomPreparePageState extends State {
return;
}
+ AppConfig.roomId = roomId;
+ AppConfig.userId = userId;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VoiceRoomPage(
userId: userId,
- roomId: int.parse(roomId),
+ roomId: roomId,
),
),
);
diff --git a/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_state.dart b/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_state.dart
index b555b3a..31bcf0c 100644
--- a/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_state.dart
+++ b/TRTC-API-Example/lib/pages/basic_rooms/voice_chat_room/voice_room_state.dart
@@ -7,6 +7,7 @@ import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_listener.dart';
import 'package:tencent_rtc_sdk/tx_device_manager.dart';
import 'package:api_example/utils/bidirectional_map.dart';
+import 'package:api_example/common/app_config.dart';
class AudioUser {
final String userId;
@@ -65,7 +66,7 @@ class VoiceRoomState extends ChangeNotifier {
bool _isLocalMicrophoneEnabled = true;
bool _isLocalSpeakerEnabled = true;
String? _localUserId;
- int? _roomId;
+ String? _roomId;
bool _isCallActive = false;
TRTCCloud? _trtcCloud;
TXDeviceManager? _deviceManager;
@@ -81,7 +82,7 @@ class VoiceRoomState extends ChangeNotifier {
bool get isLocalMicrophoneEnabled => _isLocalMicrophoneEnabled;
bool get isLocalSpeakerEnabled => _isLocalSpeakerEnabled;
String? get localUserId => _localUserId;
- int? get roomId => _roomId;
+ String? get roomId => _roomId;
bool get isCallActive => _isCallActive;
List get audioUsers => _audioUsers.values.toList();
bool get isInitialized => _isInitialized;
@@ -95,7 +96,7 @@ class VoiceRoomState extends ChangeNotifier {
Future initializeRoom({
required String userId,
- required int roomId,
+ required String roomId,
}) async {
_localUserId = userId;
_roomId = roomId;
@@ -118,10 +119,11 @@ class VoiceRoomState extends ChangeNotifier {
}
_statusMessage = 'Entering room...';
+ final roomIdStr = _roomId ?? AppConfig.defaultRoomId;
_trtcCloud?.enterRoom(TRTCParams(
sdkAppId: GenerateTestUserSig.sdkAppId,
userId: _localUserId ?? "",
- roomId: _roomId ?? 123456,
+ strRoomId: roomIdStr,
role: _isAnchor ? TRTCRoleType.anchor : TRTCRoleType.audience,
userSig: GenerateTestUserSig.genTestSig(_localUserId!)
), TRTCAppScene.voiceChatRoom);
diff --git a/TRTC-API-Example/pubspec.yaml b/TRTC-API-Example/pubspec.yaml
index 9b9bb8b..1d076a0 100644
--- a/TRTC-API-Example/pubspec.yaml
+++ b/TRTC-API-Example/pubspec.yaml
@@ -40,6 +40,7 @@ dependencies:
fluttertoast: 8.2.12
path_provider: ^2.1.5
file: ^6.0.0
+ shared_preferences: ^2.2.2
tencent_rtc_sdk: ^13.4.1
# fluttertoast:
diff --git a/TRTC-Simple-Demo/lib/common/app_config.dart b/TRTC-Simple-Demo/lib/common/app_config.dart
new file mode 100644
index 0000000..a02c116
--- /dev/null
+++ b/TRTC-Simple-Demo/lib/common/app_config.dart
@@ -0,0 +1,23 @@
+import 'package:shared_preferences/shared_preferences.dart';
+
+class AppConfig {
+ static const defaultRoomId = '20260710';
+
+ static late SharedPreferences _prefs;
+
+ static String _roomId = defaultRoomId;
+ static String _userId = DateTime.now()
+ .millisecondsSinceEpoch.remainder(100000).toString().padLeft(5, '0');
+
+ static Future init() async {
+ _prefs = await SharedPreferences.getInstance();
+ _roomId = _prefs.getString('room_id') ?? _roomId;
+ _userId = _prefs.getString('user_id') ?? _userId;
+ }
+
+ static String get roomId => _roomId;
+ static set roomId(String v) { _roomId = v; _prefs.setString('room_id', v); }
+
+ static String get userId => _userId;
+ static set userId(String v) { _userId = v; _prefs.setString('user_id', v); }
+}
diff --git a/TRTC-Simple-Demo/lib/main.dart b/TRTC-Simple-Demo/lib/main.dart
index 139d4f8..cc8723a 100644
--- a/TRTC-Simple-Demo/lib/main.dart
+++ b/TRTC-Simple-Demo/lib/main.dart
@@ -1,12 +1,15 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
+import 'package:trtc_demo/common/app_config.dart';
import 'package:trtc_demo/ui/login.dart';
import 'package:trtc_demo/ui/meeting.dart';
import 'package:trtc_demo/ui/member_list.dart';
import 'package:trtc_demo/ui/test/test_api.dart';
import 'package:trtc_demo/models/meeting_model.dart';
-void main() {
+void main() async {
+ WidgetsFlutterBinding.ensureInitialized();
+ await AppConfig.init();
runApp(MyApp());
}
diff --git a/TRTC-Simple-Demo/lib/models/meeting_model.dart b/TRTC-Simple-Demo/lib/models/meeting_model.dart
index a0183e4..c68923e 100644
--- a/TRTC-Simple-Demo/lib/models/meeting_model.dart
+++ b/TRTC-Simple-Demo/lib/models/meeting_model.dart
@@ -5,7 +5,7 @@ import 'package:trtc_demo/models/user_model.dart';
class MeetingModel extends ChangeNotifier {
/// Internal, private state of the cart.
- int? _meetId;
+ String? _meetId;
TRTCAudioQuality _quality = TRTCAudioQuality.defaultMode;
late UserModel _userInfo;
@@ -24,7 +24,7 @@ class MeetingModel extends ChangeNotifier {
}
void setUserSettings(
- {required int meetId,
+ {required String meetId,
required String userId,
required bool enabledCamera,
required bool enabledMicrophone,
@@ -36,7 +36,7 @@ class MeetingModel extends ChangeNotifier {
_quality = quality;
}
- int? getMeetId() {
+ String? getMeetId() {
return _meetId;
}
diff --git a/TRTC-Simple-Demo/lib/ui/login.dart b/TRTC-Simple-Demo/lib/ui/login.dart
index 0680dfb..9c3242d 100644
--- a/TRTC-Simple-Demo/lib/ui/login.dart
+++ b/TRTC-Simple-Demo/lib/ui/login.dart
@@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:tencent_rtc_sdk/trtc_cloud_def.dart';
import 'package:permission_handler/permission_handler.dart';
+import 'package:trtc_demo/common/app_config.dart';
import 'package:trtc_demo/debug/GenerateTestUserSig.dart';
import 'package:trtc_demo/models/meeting_model.dart';
import 'package:trtc_demo/utils/tool.dart';
@@ -39,6 +40,8 @@ class LoginPageState extends State {
@override
initState() {
super.initState();
+ _meetId = AppConfig.roomId;
+ _userId = AppConfig.userId;
}
_unFocus() {
@@ -68,17 +71,6 @@ class LoginPageState extends State {
if (_meetId == '') {
MeetingTool.toast('Please enter the conference number', context);
return;
- } else if (_meetId == '0') {
- MeetingTool.toast('Please enter the legal meeting ID', context);
- return;
- } else if (_meetId.toString().length > 10) {
- MeetingTool.toast('Please enter a valid conference ID', context);
- return;
- } else if (!new RegExp(r"[0-9]+$").hasMatch(_meetId)) {
- MeetingTool.toast(
- 'Conference ID can only be numeric. Please enter a legal conference ID',
- context);
- return;
}
_userId = _userId.replaceAll(new RegExp(r"\s+\b|\b\s"), "");
if (_userId == '') {
@@ -106,10 +98,12 @@ class LoginPageState extends State {
await Permission.systemAlertWindow.request();
}
+ AppConfig.roomId = _meetId;
+ AppConfig.userId = _userId;
var meetModel = context.read();
meetModel.setUserSettings(
- meetId: int.parse(_meetId),
+ meetId: _meetId,
userId: _userId,
enabledCamera: _enabledCamera,
enabledMicrophone: _enabledMicrophone,
@@ -125,6 +119,7 @@ class LoginPageState extends State {
style: TextStyle(color: Colors.white),
autofocus: false,
focusNode: _meetIdFocusNode,
+ controller: TextEditingController(text: _meetId),
decoration: InputDecoration(
labelText: "Conference number",
hintText: "Please enter the conference number",
@@ -135,12 +130,12 @@ class LoginPageState extends State {
borderSide: BorderSide(color: Colors.white),
),
),
- keyboardType: TextInputType.number,
onChanged: (value) => _meetId = value),
TextField(
style: TextStyle(color: Colors.white),
autofocus: false,
focusNode: _userFocusNode,
+ controller: TextEditingController(text: _userId),
decoration: InputDecoration(
labelText: "User ID",
hintText: "Please enter user ID",
diff --git a/TRTC-Simple-Demo/lib/ui/meeting.dart b/TRTC-Simple-Demo/lib/ui/meeting.dart
index 71bf998..b46585e 100644
--- a/TRTC-Simple-Demo/lib/ui/meeting.dart
+++ b/TRTC-Simple-Demo/lib/ui/meeting.dart
@@ -323,7 +323,7 @@ class MeetingPageState extends State with WidgetsBindingObserver {
userId: _meetModel.getUserInfo().userId,
userSig: _meetModel.getUserInfo().userSig ?? '',
role: TRTCRoleType.anchor,
- roomId: _meetModel.getMeetId()!),
+ strRoomId: _meetModel.getMeetId() ?? ''),
TRTCAppScene.live);
}
@@ -611,7 +611,7 @@ class MeetingPageState extends State with WidgetsBindingObserver {
_meetModel.getUserInfo().isFrontCamera = !_meetModel.getUserInfo().isFrontCamera;
});
}),
- Text(_meetModel.getMeetId().toString(),
+ Text(_meetModel.getMeetId() ?? '',
style: TextStyle(fontSize: 20, color: Colors.white)),
TextButton(
style: TextButton.styleFrom(
diff --git a/TRTC-Simple-Demo/lib/ui/test/test_api.dart b/TRTC-Simple-Demo/lib/ui/test/test_api.dart
index ab81c26..2aef01e 100644
--- a/TRTC-Simple-Demo/lib/ui/test/test_api.dart
+++ b/TRTC-Simple-Demo/lib/ui/test/test_api.dart
@@ -154,7 +154,7 @@ class TestPageState extends State {
name: 'roomId',
type: ParameterType.tClass,
value: TRTCSwitchRoomConfig(
- roomId: meetModel.getMeetId()!,
+ strRoomId: meetModel.getMeetId() ?? '',
userSig: GenerateTestUserSig.genTestSig(userInfo.userId),
),
),
diff --git a/TRTC-Simple-Demo/pubspec.yaml b/TRTC-Simple-Demo/pubspec.yaml
index dab777e..bef4f00 100644
--- a/TRTC-Simple-Demo/pubspec.yaml
+++ b/TRTC-Simple-Demo/pubspec.yaml
@@ -14,6 +14,7 @@ dependencies:
dio: ^4.0.6
path_provider: ^2.0.15
permission_handler: ^11.3.1
+ shared_preferences: ^2.2.2
# replay_kit_launcher: ^0.3.0
tencent_rtc_sdk: ^13.4.1
flutter: