1 line
11 KiB
JSON
1 line
11 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.array.push.js\";\nimport { getUsersig } from '@/api/home';\nimport { getWidth, getHeight } from \"@/utils/utils\";\nimport roomFooter from './components/roomFooter.vue';\nimport TRTC from 'trtc-sdk-v5';\nlet trtc = null;\nexport default {\n name: 'App',\n components: {\n roomFooter\n },\n data() {\n return {\n userClass: \"userVideo5\",\n userList: [],\n userHeight: '100%',\n userSign: \"\",\n roomId: \"\",\n userId: null,\n showFlag: false\n };\n },\n methods: {\n // 鼠标滑过显示操作栏\n mouseHover() {\n this.showFlag = true;\n setTimeout(() => {\n this.showFlag = false;\n }, 4000);\n },\n // async exitRoom() {\n // await trtc.exitRoom();\n // await trtc.updateLocalVideo({ publish: false });\n // await trtc.updateLocalAudio({ publish: false });\n // await trtc.destroy();\n // this.$router.push({\n // name: \"Home\"\n // })\n // this.$router.go(-1)\n // },\n getPushVideo() {\n trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {\n const userId = event.userId;\n const streamType = event.streamType;\n this.userList.push(userId);\n this.userClass = getWidth(this.userList);\n this.userHeight = getHeight(this.userList);\n setTimeout(() => {\n trtc.startRemoteVideo({\n userId,\n streamType,\n view: `${userId}`\n });\n });\n });\n },\n deletePushVideo() {\n trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {\n const userId = event.userId;\n let deleteIndex = this.userList.indexOf(userId);\n this.userList = this.userList.filter(item => item !== userId);\n if (deleteIndex !== -1) {\n this.userList.splice(deleteIndex, 1);\n }\n this.userClass = getWidth(this.userList);\n this.userHeight = getHeight(this.userList);\n });\n }\n },\n async mounted() {\n let roomId = this.$route.query.roomId;\n this.roomId = this.$route.query.roomId;\n let userId = this.$route.query.userId;\n this.userId = this.$route.query.userId;\n const sdkAppId = 1600011167;\n // 获取usersign\n await getUsersig(userId).then(res => {\n this.userSign = res.msg;\n });\n this.getPushVideo();\n this.deletePushVideo();\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 this.$message({\n message: \"进房成功\",\n type: 'success'\n });\n } catch (error) {\n console.error('进房失败 ' + error);\n this.$message({\n message: \"进房失败\",\n type: 'error'\n });\n this.$router.push({\n name: 'Home'\n });\n }\n },\n created() {\n trtc = TRTC.create();\n }\n};","map":{"version":3,"names":["getUsersig","getWidth","getHeight","roomFooter","TRTC","trtc","name","components","data","userClass","userList","userHeight","userSign","roomId","userId","showFlag","methods","mouseHover","setTimeout","getPushVideo","on","EVENT","REMOTE_VIDEO_AVAILABLE","event","streamType","push","startRemoteVideo","view","deletePushVideo","REMOTE_VIDEO_UNAVAILABLE","deleteIndex","indexOf","filter","item","splice","mounted","$route","query","sdkAppId","then","res","msg","enterRoom","Number","scene","userSig","startLocalVideo","document","getElementById","startLocalAudio","console","log","$message","message","type","error","$router","created","create"],"sources":["src/views/room.vue"],"sourcesContent":["<template>\n <div class=\"roompage\" @mouseover=\"mouseHover\">\n <div :class=\"userClass\" :style=\"{ height: userHeight }\" id=\"localStream\">\n <div class=\"userName\">{{ userId }}</div>\n </div>\n <div :class=\"userClass\" :style=\"{ height: userHeight }\" v-for=\"(item, index) in userList\" :key=\"index\" :id=\"item\">\n <div class=\"userName\">{{item}}</div>\n </div>\n <div class=\"footer\" v-if=\"showFlag\">\n <roomFooter :roomId=\"roomId\"></roomFooter>\n </div>\n </div>\n</template>\n \n<script>\nimport { getUsersig } from '@/api/home';\nimport { getWidth, getHeight } from \"@/utils/utils\";\nimport roomFooter from './components/roomFooter.vue';\nimport TRTC from 'trtc-sdk-v5';\nlet trtc = null;\nexport default {\n name: 'App',\n components: {\n roomFooter\n },\n data() {\n return {\n userClass: \"userVideo5\",\n userList: [],\n userHeight: '100%',\n userSign: \"\",\n roomId: \"\",\n userId:null,\n showFlag:false,\n };\n },\n methods: {\n // 鼠标滑过显示操作栏\n mouseHover(){\n this.showFlag = true;\n setTimeout(()=>{\n this.showFlag = false;\n },4000)\n },\n // async exitRoom() {\n // await trtc.exitRoom();\n // await trtc.updateLocalVideo({ publish: false });\n // await trtc.updateLocalAudio({ publish: false });\n // await trtc.destroy();\n // this.$router.push({\n // name: \"Home\"\n // })\n // this.$router.go(-1)\n // },\n getPushVideo() {\n trtc.on(TRTC.EVENT.REMOTE_VIDEO_AVAILABLE, event => {\n const userId = event.userId;\n const streamType = event.streamType;\n this.userList.push(userId);\n this.userClass = getWidth(this.userList);\n this.userHeight = getHeight(this.userList);\n setTimeout(() => {\n trtc.startRemoteVideo({ userId, streamType, view: `${userId}` })\n })\n })\n },\n deletePushVideo() {\n trtc.on(TRTC.EVENT.REMOTE_VIDEO_UNAVAILABLE, event => {\n const userId = event.userId;\n let deleteIndex = this.userList.indexOf(userId);\n this.userList = this.userList.filter(item => item !== userId);\n if (deleteIndex !== -1) {\n this.userList.splice(deleteIndex, 1)\n }\n this.userClass = getWidth(this.userList);\n this.userHeight = getHeight(this.userList);\n })\n }\n },\n async mounted() {\n let roomId = this.$route.query.roomId;\n this.roomId = this.$route.query.roomId;\n let userId = this.$route.query.userId;\n this.userId = this.$route.query.userId;\n const sdkAppId = 1600011167;\n // 获取usersign\n await getUsersig(userId).then(res => {\n this.userSign = res.msg;\n })\n this.getPushVideo();\n this.deletePushVideo();\n try {\n await trtc.enterRoom({ roomId: Number(roomId), scene: 'rtc', sdkAppId, userId, userSig: this.userSign });\n await trtc.startLocalVideo({\n view: document.getElementById('localStream'), // 在 DOM 中的 elementId 为 localStream 的标签上预览视频。\n });\n await trtc.startLocalAudio();\n console.log('进房成功');\n this.$message({\n message: \"进房成功\",\n type: 'success'\n })\n } catch (error) {\n console.error('进房失败 ' + error);\n this.$message({\n message: \"进房失败\",\n type: 'error'\n });\n this.$router.push({\n name: 'Home'\n })\n }\n },\n created() {\n trtc = TRTC.create();\n },\n};\n</script>\n \n<style scoped>\n.roompage {\n width: 100%;\n height: 100vh;\n display: flex;\n align-items: center;\n justify-content: space-around;\n flex-wrap: wrap;\n position: relative;\n}\n.userVideo,.userVideo1,.userVideo2,.userVideo3,.userVideo4,.userVideo5{\n position: relative;\n}\n.userVideo5 {\n width: 100%;\n background-color: yellow;\n}\n\n.userVideo {\n width: 48%;\n background-color: yellow;\n}\n\n.userVideo1 {\n width: 33%;\n background-color: yellow;\n}\n\n.userVideo2 {\n width: 33%;\n background-color: yellow;\n}\n\n.userVideo3 {\n width: 33%;\n background-color: yellow;\n}\n\n.userVideo4 {\n width: 100%;\n background-color: yellow;\n}\n\n.footer {\n width: 100%;\n height: 10%;\n background: rgb(46 43 43 / 90%);\n position: absolute;\n bottom: 0;\n z-index: 10;\n}\n.userName{\n border-radius: 10px;\n width: 90px;\n height: 40px;\n text-align: center;\n line-height: 40px;\n background-color: black;\n position: absolute;\n right: 0;\n bottom: 0;\n z-index: 9;\n color: #ffffff;\n}\n</style>\n \n \n "],"mappings":";AAeA,SAAAA,UAAA;AACA,SAAAC,QAAA,EAAAC,SAAA;AACA,OAAAC,UAAA;AACA,OAAAC,IAAA;AACA,IAAAC,IAAA;AACA;EACAC,IAAA;EACAC,UAAA;IACAJ;EACA;EACAK,KAAA;IACA;MACAC,SAAA;MACAC,QAAA;MACAC,UAAA;MACAC,QAAA;MACAC,MAAA;MACAC,MAAA;MACAC,QAAA;IACA;EACA;EACAC,OAAA;IACA;IACAC,WAAA;MACA,KAAAF,QAAA;MACAG,UAAA;QACA,KAAAH,QAAA;MACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACAI,aAAA;MACAd,IAAA,CAAAe,EAAA,CAAAhB,IAAA,CAAAiB,KAAA,CAAAC,sBAAA,EAAAC,KAAA;QACA,MAAAT,MAAA,GAAAS,KAAA,CAAAT,MAAA;QACA,MAAAU,UAAA,GAAAD,KAAA,CAAAC,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