123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- import 'package:get/get.dart';
- class HardwareDetectionState {
- /// *** 数据层状态 ***
- ///
- /// 数据层状态是指在 [Controller] 中的状态,用于控制数据的获取和存储。
- /// 设备列表
- List<HardwareDevice> _deviceList = [];
- set deviceList(List<HardwareDevice> value) => _deviceList = value;
- List<HardwareDevice> get deviceList => _deviceList;
- /// *** UI 层状态 ***
- ///
- /// UI 层状态是指在 [View] 中的状态,用于控制页面的显示效果。
- /// UI 层状态通常是通过 [Rx] 类型的变量来实现的。
- /// 摄像头初始化完成
- RxBool _isDisplayCameraWindow = RxBool(false);
- /// 扬声器初始化完成
- RxBool _isDisplaySpeakerWave = RxBool(false);
- /// 麦克风初始化完成
- RxBool _isDisplayMicrophoneWave = RxBool(false);
- /// 摄像头列表
- RxList<HardwareDevice> _cameraList = RxList<HardwareDevice>([]);
- /// 麦克风列表
- RxList<HardwareDevice> _microphoneList = RxList<HardwareDevice>([]);
- /// 扬声器列表
- RxList<HardwareDevice> _speakerList = RxList<HardwareDevice>([]);
- /// 当前选中的摄像头
- Rx<HardwareDevice?> _currentCamera = Rx<HardwareDevice?>(null);
- /// 当前选中的麦克风
- Rx<HardwareDevice?> _currentMicrophone = Rx<HardwareDevice?>(null);
- /// 当前选中的扬声器
- Rx<HardwareDevice?> _currentSpeaker = Rx<HardwareDevice?>(null);
- /// 当前摄像头可用性
- Rx<bool?> _cameraAvailable = Rx(null);
- /// 当前麦克风可用性
- Rx<bool?> _microphoneAvailable = Rx(null);
- /// 当前扬声器可用性
- Rx<bool?> _speakerAvailable = Rx(null);
- /// 是否正在检测摄像头
- RxBool _detectingCamera = RxBool(false);
- /// 是否正在检测麦克风
- RxBool _detectingMicrophone = RxBool(false);
- /// 是否正在检测扬声器
- RxBool _detectingSpeaker = RxBool(false);
- set isDisplayMicrophoneWave(bool value) =>
- _isDisplayMicrophoneWave.value = value;
- bool get isDisplayMicrophoneWave => _isDisplayMicrophoneWave.value;
- set isDisplaySpeakerWave(bool value) => _isDisplaySpeakerWave.value = value;
- bool get isDisplaySpeakerWave => _isDisplaySpeakerWave.value;
- set isDisplayCameraWindow(bool value) => _isDisplayCameraWindow.value = value;
- bool get isDisplayCameraWindow => _isDisplayCameraWindow.value;
- set cameraList(List<HardwareDevice> value) => _cameraList.value = value;
- List<HardwareDevice> get cameraList => _cameraList;
- set currentCamera(HardwareDevice? value) => _currentCamera = Rx(value);
- HardwareDevice? get currentCamera => _currentCamera.value;
- set microphoneList(List<HardwareDevice> value) =>
- _microphoneList.value = value;
- List<HardwareDevice> get microphoneList => _microphoneList;
- set currentMicrophone(HardwareDevice? value) =>
- _currentMicrophone = Rx(value);
- HardwareDevice? get currentMicrophone => _currentMicrophone.value;
- set speakerList(List<HardwareDevice> value) => _speakerList.value = value;
- List<HardwareDevice> get speakerList => _speakerList;
- set currentSpeaker(HardwareDevice? value) => _currentSpeaker = Rx(value);
- HardwareDevice? get currentSpeaker => _currentSpeaker.value;
- set cameraAvailable(bool? value) => _cameraAvailable.value = value;
- bool? get cameraAvailable => _cameraAvailable.value;
- set microphoneAvailable(bool? value) => _microphoneAvailable.value = value;
- bool? get microphoneAvailable => _microphoneAvailable.value;
- set speakerAvailable(bool? value) => _speakerAvailable.value = value;
- bool? get speakerAvailable => _speakerAvailable.value;
- set detectingCamera(bool value) => _detectingCamera.value = value;
- bool get detectingCamera => _detectingCamera.value;
- set detectingMicrophone(bool value) => _detectingMicrophone.value = value;
- bool get detectingMicrophone => _detectingMicrophone.value;
- set detectingSpeaker(bool value) => _detectingSpeaker.value = value;
- bool get detectingSpeaker => _detectingSpeaker.value;
- }
- class HardwareDevice {
- /// 设备名称
- String name;
- /// 设备id
- String id;
- /// 设备类型
- HardwareDeviceType type;
- HardwareDevice({required this.name, required this.id, required this.type});
- }
- enum HardwareDeviceType {
- /// 摄像头
- camera,
- /// 扬声器
- speaker,
- /// 麦克风
- microphone,
- }
|