更新
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { ref } from 'vue';
|
||||
import { AudioPlayBackDevice } from '@trtc/call-engine-lite-wx';
|
||||
import {
|
||||
TUIStore,
|
||||
StoreName,
|
||||
TUICallKitServer,
|
||||
NAME,
|
||||
} from './TUICallService/index';
|
||||
import { DeviceStatus } from '../constants/call';
|
||||
|
||||
const microphoneStatus = ref<DeviceStatus>(DeviceStatus.OFF);
|
||||
const cameraStatus = ref<DeviceStatus>(DeviceStatus.OFF);
|
||||
const isFrontCamera = ref<boolean>(true);
|
||||
const currentAudioRoute = ref<string>(AudioPlayBackDevice.EAR);
|
||||
|
||||
// const localVideoQuality = ref();
|
||||
|
||||
const openLocalCamera = async () => await TUICallKitServer.openCamera('localVideo');
|
||||
const closeLocalCamera = async () => await TUICallKitServer.closeCamera();
|
||||
const switchCamera = async () => await TUICallKitServer.switchCamera();
|
||||
const openLocalMicrophone = async () => await TUICallKitServer.openMicrophone();
|
||||
const closeLocalMicrophone = async () => await TUICallKitServer.closeMicrophone();
|
||||
const setAudioRoute = async () => await TUICallKitServer.setSoundMode();
|
||||
|
||||
TUIStore?.watch(StoreName.CALL, {
|
||||
[NAME.CAMERA_POSITION]: _handleCameraPositionChange,
|
||||
[NAME.IS_EAR_PHONE]: _handleIsEarPhoneChange,
|
||||
});
|
||||
|
||||
function _handleCameraPositionChange(value: boolean) {
|
||||
isFrontCamera.value = value;
|
||||
}
|
||||
|
||||
function _handleIsEarPhoneChange(value: boolean) {
|
||||
currentAudioRoute.value = value ? AudioPlayBackDevice.EAR : AudioPlayBackDevice.SPEAKER;
|
||||
}
|
||||
|
||||
function useDeviceState() {
|
||||
return {
|
||||
// state
|
||||
microphoneStatus,
|
||||
cameraStatus,
|
||||
// localVideoQuality,
|
||||
isFrontCamera,
|
||||
currentAudioRoute,
|
||||
// captureVolume,
|
||||
// networkInfo,
|
||||
|
||||
// actions
|
||||
openLocalMicrophone,
|
||||
closeLocalMicrophone,
|
||||
openLocalCamera,
|
||||
closeLocalCamera,
|
||||
switchCamera,
|
||||
setAudioRoute,
|
||||
};
|
||||
}
|
||||
|
||||
export { useDeviceState };
|
||||
|
||||
Reference in New Issue
Block a user