Files
Arbitrate-FrontendH5/node_modules/.cache/babel-loader/0f2491bd5d8d7637305fce71fdbfbbccc974adf2575c0bc15c8c4751019b49e9.json
T

1 line
7.1 KiB
JSON
Raw Normal View History

2024-01-18 10:46:33 +08:00
{"ast":null,"code":"import \"core-js/modules/es.array.push.js\";\nimport { getUsersig } from '@/api/home';\nimport TRTC from 'trtc-sdk-v5';\nconst trtc = TRTC.create();\nexport default {\n name: 'App',\n components: {},\n data() {\n return {\n userClass: \"userVideo\",\n userList: [],\n userHeight: '100%',\n userSign: \"\"\n };\n },\n methods: {},\n async mounted() {\n let roomId = this.$route.query.roomId;\n let userId = this.$route.query.userId;\n const sdkAppId = 1600011167;\n // 获取usersign\n await getUsersig(userId).then(res => {\n this.userSign = res.msg;\n });\n await trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE, event => {\n const userId = event.userId;\n const streamType = event.streamType;\n this.userList.push(userId);\n trtc.startRemoteVideo({\n userId,\n streamType,\n view: `hcb`\n });\n });\n try {\n await trtc.enterRoom({\n roomId: Number(roomId),\n scene: 'rtc',\n sdkAppId,\n userId,\n userSig: this.userSign\n });\n await trtc.startLocalVideo({\n view: document.getElementById('localStream') // 在 DOM 中的 elementId 为 localStream 的标签上预览视频。\n });\n\n await trtc.startLocalAudio();\n console.log('进房成功');\n } catch (error) {\n console.error('进房失败 ' + error);\n }\n },\n created() {\n // 判断房间人数对应的样式\n if (this.userList.length == 1) {\n this.userClass = 'userVideo';\n } else if (this.userList.length == 2) {\n this.userClass = \"userVideo1\";\n } else if (this.userList.length == 3) {\n this.userClass = \"userVideo2\";\n } else if (this.userList.length > 3) {\n this.userClass = \"userVideo3\";\n } else if (this.userList.length == 0) {\n this.userClass = 'userVideo4';\n }\n let userRow = Math.ceil((this.userList.length + 1) / 3);\n console.log(userRow, \"l\");\n if (userRow == 1) {\n this.userHeight == \"100%\";\n } else {\n this.userHeight = 1 / userRow * 100 + \"%\";\n }\n }\n};","map":{"version":3,"names":["getUsersig","TRTC","trtc","create","name","components","data","userClass","userList","userHeight","userSign","methods","mounted","roomId","$route","query","userId","sdkAppId","then","res","msg","on","EVENT","REMOTE_AUDIO_AVAILABLE","event","streamType","push","startRemoteVideo","view","enterRoom","Number","scene","userSig","startLocalVideo","document","getElementById","startLocalAudio","console","log","error","created","length","userRow","Math","ceil"],"sources":["src/views/room.vue"],"sourcesContent":["<template>\n <div class=\"roompage\">\n <div :class=\"userClass\" :style=\"{ height: userHeight }\" id=\"localStream\"></div>\n <div :class=\"userClass\" :style=\"{ height: userHeight }\" id=\"hcb\"></div>\n </div>\n</template>\n \n<script>\nimport { getUsersig } from '@/api/home';\nimport TRTC from 'trtc-sdk-v5';\nconst trtc = TRTC.create();\nexport default {\n name: 'App',\n components: {\n },\n data() {\n return {\n userClass: \"userVideo\",\n userList: [],\n userHeight: '100%',\n userSign:\"\"\n };\n },\n methods: {\n\n },\n async mounted() {\n let roomId = this.$route.query.roomId;\n let userId = this.$route.query.userId;\n const sdkAppId = 1600011167;\n // 获取usersign\n await getUsersig(userId).then(res => {\n this.userSign = res.msg;\n })\n await trtc.on(TRTC.EVENT.REMOTE_AUDIO_AVAILABLE,event=>{\n const userId = event.userId;\n const streamType = event.streamType;\n this.userList.push(userId);\n trtc.startRemoteVideo({userId,streamType,view:`hcb`})\n })\n try {\n await trtc.enterRoom({ roomId: Number(roomId), scene: 'rtc', sdkAppId, userId, userSig:this.userSign });\n await trtc.startLocalVideo({\n view: document.getElementB