老师端几乎ok
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
import 'package:app/config/config.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
|
||||
import '../../request/dto/room/rtc_token_dto.dart';
|
||||
|
||||
/// 视频画面显示状态
|
||||
enum VideoState {
|
||||
@@ -18,26 +21,60 @@ enum VideoState {
|
||||
error,
|
||||
}
|
||||
|
||||
class VideoSurface extends StatelessWidget {
|
||||
final VideoState state;
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
|
||||
const VideoSurface({super.key, this.state = VideoState.normal});
|
||||
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,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@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();
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user