优化了老师端的等待状态判断逻辑
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:agora_rtc_engine/agora_rtc_engine.dart';
|
||||
import 'package:app/config/config.dart';
|
||||
import 'package:app/providers/user_store.dart';
|
||||
import 'package:app/request/dto/room/room_info_dto.dart';
|
||||
import 'package:app/request/dto/room/room_type_dto.dart';
|
||||
@@ -36,12 +38,48 @@ class StuRoomVM extends ChangeNotifier {
|
||||
final RoomWebSocket _ws = RoomWebSocket();
|
||||
StreamSubscription<RoomMessage>? _sub;
|
||||
|
||||
RtcTokenDto? get rtcToken => _ws.rtcToken;
|
||||
/// 声网sdk管理
|
||||
RtcEngine? _engine;
|
||||
|
||||
RtcEngine? get engine => _engine;
|
||||
|
||||
StuRoomVM({required this.roomInfo, required this.uid}) {
|
||||
_startRoom();
|
||||
}
|
||||
|
||||
///初始化声网
|
||||
Future<void> _initRtc() async {
|
||||
_engine = createAgoraRtcEngine();
|
||||
//初始化 RtcEngine,设置频道场景为 channelProfileLiveBroadcasting(直播场景)
|
||||
await _engine!.initialize(
|
||||
RtcEngineContext(
|
||||
appId: Config.swAppId,
|
||||
channelProfile: ChannelProfileType.channelProfileCommunication,
|
||||
),
|
||||
);
|
||||
//启动视频模块
|
||||
await _engine!.enableVideo();
|
||||
//加入频道
|
||||
await _engine!.joinChannel(
|
||||
token: _ws.rtcToken!.token,
|
||||
channelId: _ws.rtcToken!.channel,
|
||||
uid: uid,
|
||||
// uid: _ws.rtcToken!.uid,
|
||||
options: ChannelMediaOptions(
|
||||
// 自动订阅所有视频流
|
||||
autoSubscribeVideo: true,
|
||||
// 自动订阅所有音频流
|
||||
autoSubscribeAudio: true,
|
||||
// 发布摄像头采集的视频
|
||||
publishCameraTrack: true,
|
||||
// 发布麦克风采集的音频
|
||||
publishMicrophoneTrack: true,
|
||||
// 设置用户角色为 clientRoleBroadcaster(主播)或 clientRoleAudience(观众)
|
||||
clientRoleType: ClientRoleType.clientRoleBroadcaster,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
///开始链接房间
|
||||
Future<void> _startRoom() async {
|
||||
//如果socket的token没有,先初始化
|
||||
|
||||
Reference in New Issue
Block a user