This commit is contained in:
zhutao
2025-11-21 18:21:47 +08:00
parent 9c94ee31fd
commit 5784a0a5d4
32 changed files with 734 additions and 441 deletions

View File

@@ -21,60 +21,26 @@ enum VideoState {
error,
}
// class VideoSurface extends StatelessWidget {
// final VideoState state;
//
// const VideoSurface({super.key, this.state = VideoState.normal});
//
// @override
// Widget build(BuildContext context) {
// String stateText = switch (state) {
// VideoState.closed => "摄像头已关闭",
// VideoState.offline => "掉线",
// VideoState.loading => "加载中",
// VideoState.error => "错误",
// _ => "未知",
// };
// //如果不是正常
// if (state != VideoState.normal) {
// return Align(
// child: Text(stateText, style: TextStyle(color: Colors.white70)),
// );
// }
// return Container();
// }
// }
class VideoSurface extends StatelessWidget {
final VideoState state;
class VideoSurface extends StatefulWidget {
final RtcTokenDto rtcToken;
final String remoteUid;
const VideoSurface({
super.key,
required this.rtcToken,
required this.remoteUid,
});
@override
State<VideoSurface> createState() => _VideoSurfaceState();
}
class _VideoSurfaceState extends State<VideoSurface> {
RtcEngine? _engine;
void _init() async {
_engine = createAgoraRtcEngine();
//初始化 RtcEngine设置频道场景为 channelProfileLiveBroadcasting直播场景
await _engine!.initialize(
RtcEngineContext(
appId: Config.swAppId,
channelProfile: ChannelProfileType.channelProfileLiveBroadcasting,
),
);
}
const VideoSurface({super.key, this.state = VideoState.normal});
@override
Widget build(BuildContext context) {
return const Placeholder();
String stateText = switch (state) {
VideoState.closed => "摄像头已关闭",
VideoState.offline => "掉线",
VideoState.loading => "加载中",
VideoState.error => "错误",
_ => "未知",
};
//如果不是正常
if (state != VideoState.normal) {
return Align(
child: Text(stateText, style: TextStyle(color: Colors.white70)),
);
}
return Container();
}
}