2 lines
4.6 KiB
JavaScript
2 lines
4.6 KiB
JavaScript
import{L as r,c as o,S as l,a as c,P as u}from"./gy.srs.sdk.ab1fd116.js";import{u as a,c as d}from"./live-manage.d907c119.js";import{n as v}from"./vueComponentNormalizer.9ef17bb1.js";import"./live-student.e6ad7a61.js";import"./index.f5168bf8.js";var f=function(){var e=this,s=e.$createElement,t=e._self._c||s;return t("LiveLayout",{staticClass:"live-student",attrs:{liveInfo:e.liveInfo,quitText:e.isPlaying?"\u7ED3\u675F\u76F4\u64AD":"\u9000\u51FA"},on:{quitLive:e.quitLive},scopedSlots:e._u([{key:"liveBodyLeftMenu",fn:function(){return[t("div",{staticClass:"live-body-left"},[t("div",{class:{"left-menu-item":!0,"left-menu-item-open":e.openMedia.mic},on:{click:function(i){return e.openMediaFun("mic")}}},[t("i",{staticClass:"i-j-jxzb-yangshengqi"}),e._v(" "+e._s(e.openMedia.mic?"\u9759\u97F3":"\u89E3\u9664\u9759\u97F3")+" ")]),t("div",{class:{"left-menu-item":!0},on:{click:function(i){return e.openMediaFun("camera")}}},[t("i",{staticClass:"i-j-jxzb--shiping"}),e._v(" \u6444\u50CF\u5934 ")])])]},proxy:!0},{key:"playingBox",fn:function(){var i;return[t("div",{directives:[{name:"show",rawName:"v-show",value:e.isPlaying,expression:"isPlaying"}],staticClass:"live-playing"},[t("video",{ref:"videoPlayer",staticClass:"video-play",attrs:{controls:"",muted:"",autoplay:""},domProps:{muted:!0}}),t("video",{ref:"cameraPlayer",staticClass:"camera-play",staticStyle:{visibility:"hidden",width:"0",height:"0",position:"fixed"},attrs:{controls:"",muted:"",autoplay:""},domProps:{muted:!0}})]),t("div",{directives:[{name:"show",rawName:"v-show",value:!e.isPlaying,expression:"!isPlaying"}],staticClass:"live-not-start"},[e._v(" \u76F4\u64AD"+e._s(((i=e.liveInfo)===null||i===void 0?void 0:i.status)==1?"\u5DF2\u6682\u505C":"\u672A\u5F00\u59CB")+"\uFF0C\u9A6C\u4E0A\u5F00\u59CB\u76F4\u64AD\u5427\uFF01 "),t("div",{staticClass:"start-button"},[t("el-button",{attrs:{type:"success",round:""},on:{click:e.startLive}},[e._v("\u5F00\u59CB\u76F4\u64AD")])],1)])]},proxy:!0}])})},m=[];const h={components:{LiveLayout:r},data(){return{liveInfo:null,openMedia:{mic:!1,screen:!1,camera:!1},isPlaying:!1}},mixins:[o],async activated(){this.room={id:this.$route.query.id},this.isPlaying=!1,this.getLiveWatchInfo()},methods:{async startLive(){await a({id:this.liveInfo.id,status:1}),this.$nextTick(async()=>{this.openMedia.mic=!0,await this.getMediaStream(this.openMedia.mic).then(()=>{this.isPlaying=!0}).catch(()=>{self.isPlaying=!1})})},async getMediaStream(e){(!e||e instanceof PointerEvent)&&(e=this.openMedia.mic),this.sdk&&this.sdk.close(),this.sdk=new l,this.$refs.videoPlayer.srcObject=this.sdk.stream;const s=window.GyConfig.webRtcUrl+this.$route.query.id,t=this;return this.sdk.publish(s,{micro:e}).catch(function(i){throw i instanceof c&&(i.name==="HttpsRequiredError"?t.$message.error("WebRTC\u63A8\u6D41\u5FC5\u987B\u662FHTTPS\u6216\u8005localhost"):console.error(`${i.name} ${i.message}`)),i instanceof DOMException&&(i.name==="NotFoundError"?t.$message.error("\u627E\u4E0D\u5230\u9EA6\u514B\u98CE\u548C\u6444\u50CF\u5934\u8BBE\u5907"):i.name==="NotAllowedError"?t.$message.error("\u4F60\u7981\u6B62\u4E86\u7F51\u9875\u8BBF\u95EE\u6444\u50CF\u5934\u548C\u9EA6\u514B\u98CE"):["AbortError","NotAllowedError","NotFoundError","NotReadableError","OverconstrainedError","SecurityError","TypeError"].includes(i.name)&&t.$message.error(`getUserMedia ${i.name} ${i.message}`)),t.sdk.close(),t.sdk=null,console.error(i),ErrorEvent()})},async getLiveWatchInfo(){const{data:e}=await d(this.room.id);this.liveInfo=e},async playCamera(){const e=new u;return this.$refs.cameraPlayer.srcObject=e.stream,this.$refs.cameraPlayer.onloadeddata=()=>{this.$refs.cameraPlayer.requestPictureInPicture()},await e.play()},openMediaFun(e){e instanceof PointerEvent||(this.openMedia[e]=!this.openMedia[e],e==="mic"&&this.sdk.muted(this.openMedia[e]),e==="camera"&&this.playCamera().catch(s=>{(s==null?void 0:s.name)==="NotFoundError"?this.$message.error("\u6CA1\u627E\u5230\u6444\u50CF\u5934"):(s==null?void 0:s.name)==="NotReadableError"&&this.$message.error("\u6444\u50CF\u5934\u753B\u9762\u8BFB\u53D6\u5931\u8D25")}))},quitLive(){if(!this.isPlaying){this.$router.replace("/online-course/live-lectures").then();return}this.$confirm("\u5373\u5C06\u7ED3\u675F\u76F4\u64AD, \u662F\u5426\u7EE7\u7EED?","\u63D0\u793A",{confirmButtonText:"\u786E\u5B9A",cancelButtonText:"\u53D6\u6D88",type:"warning"}).then(async()=>{await a({id:this.liveInfo.id,status:2}),this.ws_finish_live(),this.$router.replace("/online-course/live-lectures").then(()=>{location.reload()})}).catch(()=>{})}}},n={};var y=v(h,f,m,!1,p,"2ba4c366",null,null);function p(e){for(let s in n)this[s]=n[s]}const w=function(){return y.exports}();export{w as default};
|