12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import consola from "consola";
- import TRTC from "trtc-js-sdk";
- import { useRtcStore } from "/@/store/modules/rtc";
- import Dialog from '/@/components/basic/dialog'
- export const updateDevice = async () => {
- console.log("updateDevice");
- const microphoneItems = await TRTC.getMicrophones();
- microphoneItems.forEach((item) => {
- console.log('item', item)
- });
- }
- const checkoutIsExistAudioInput = async () => {
- const result = await TRTC.checkSystemRequirements()
- console.log('result', result)
- }
- // interface UseRtcSdkType {
- // createRTCSocket: () => Promise<void>
- // }
- async function createRTCSocket(): Promise<void> {
- try {
- console.log('Dialog', Dialog)
- // Dialog.alert("该场景正在计算中,请稍后再试");
- const rtcStore = useRtcStore()
- await checkoutIsExistAudioInput();
- const microphoneItems = await TRTC.getMicrophones();
- // debugger
- if (microphoneItems?.length) {
- const localStream = TRTC.createStream({
- userId: rtcStore.userId,
- audio: true,
- video: false,
- // microphoneId: store.getters["rtc/audioDeviceId"],
- microphoneId: rtcStore.audioDeviceId
- });
- console.log('localStream', localStream)
- }
- } catch (error) {
- consola.error({
- tag: 'createRTCSocket',
- message: error
- })
- }
- }
- export function useRtcSdk() {
- return {
- createRTCSocket
- }
- }
|