|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <div class="live-container">
|
|
|
<div>
|
|
|
<div class="page-title">直播间</div>
|
|
|
<div class="title"></div>
|
|
@@ -16,23 +16,54 @@ export default {
|
|
|
name: 'Live',
|
|
|
data() {
|
|
|
return {
|
|
|
- userid: '',
|
|
|
- roomid: '',
|
|
|
- sessionid: '',
|
|
|
+ userid: '53A22FC29AD2216D',
|
|
|
+ roomid: 'DCDD385394BFEDEB9C33DC5901307461',
|
|
|
+ sessionid: 'C94A8844123446A560B4B9BAD28543A1C206D3CB38AEB9A330590FFD7863F3D3',
|
|
|
rtc: null,
|
|
|
- roomData: null
|
|
|
+ roomData: null,
|
|
|
+ loadedNumber: 0
|
|
|
};
|
|
|
},
|
|
|
- mounted() {
|
|
|
- common.initSDK({
|
|
|
- userid: this.userid,
|
|
|
- roomid: this.roomid,
|
|
|
- sessionid: this.sessionid
|
|
|
- });
|
|
|
- common.initListener(); // 注册监听事件
|
|
|
- window.rtc = this.rtc;
|
|
|
+ created() {
|
|
|
+ this.downloadWebSDK();
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ loadedNumber(newValue) {
|
|
|
+ if (newValue === 2) {
|
|
|
+ this.initSDK();
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
+ downloadWebSDK() {
|
|
|
+ let script = this.createScript('https://class.csslcloud.net/static/dist/js/websdk_4.0.js');
|
|
|
+
|
|
|
+ script.onload = () => {
|
|
|
+ this.loadedNumber = this.loadedNumber + 1;
|
|
|
+ let classMode = this.createScript(
|
|
|
+ 'https://class.csslcloud.net/static/dist/js/classMode.js'
|
|
|
+ );
|
|
|
+ classMode.onload = () => {
|
|
|
+ this.loadedNumber = this.loadedNumber + 1;
|
|
|
+ };
|
|
|
+ };
|
|
|
+ },
|
|
|
+ createScript(url) {
|
|
|
+ let script = document.createElement('script');
|
|
|
+ script.type = 'text/javascript';
|
|
|
+ script.src = url;
|
|
|
+ document.getElementsByTagName('body')[0].appendChild(script);
|
|
|
+ return script;
|
|
|
+ },
|
|
|
+ initSDK() {
|
|
|
+ common.initSDK({
|
|
|
+ userid: this.userid,
|
|
|
+ roomid: this.roomid,
|
|
|
+ sessionid: this.sessionid
|
|
|
+ });
|
|
|
+ common.initListener(); // 注册监听事件
|
|
|
+ window.rtc = this.rtc;
|
|
|
+ },
|
|
|
startLive() {
|
|
|
common.startLive(); // 开启直播
|
|
|
},
|
|
@@ -42,15 +73,21 @@ export default {
|
|
|
createLocalStream() {
|
|
|
common.createLocalStream(); // 创建本地流
|
|
|
},
|
|
|
- publistStream() {
|
|
|
- common.publistStream(); // 推流
|
|
|
+ publishStream() {
|
|
|
+ common.publishStream(); // 推流
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
|
-.page-title {
|
|
|
- font-size: 12px;
|
|
|
+@import '~@/styles/mixin.scss';
|
|
|
+
|
|
|
+.live-container {
|
|
|
+ @include container;
|
|
|
+
|
|
|
+ .page-title {
|
|
|
+ font-size: 12px;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|