dusenyao 4 rokov pred
rodič
commit
9e696cf054
2 zmenil súbory, kde vykonal 21 pridanie a 6 odobranie
  1. 5 0
      src/views/live/index.vue
  2. 16 6
      src/views/live/live.js

+ 5 - 0
src/views/live/index.vue

@@ -9,6 +9,7 @@
           <span class="live-name">{{ roomData.name }}</span>
         </div>
         <div>
+          <el-button @click="getDevice">获取设备列表</el-button>
           <template v-if="userType === 'TEACHER'">
             <el-button v-if="!liveStat" @click="startLive">开启直播</el-button>
             <el-button v-if="liveStat" @click="closeLiveRoom">结束直播</el-button>
@@ -391,6 +392,10 @@ export default {
       common.drawChange(action, value);
     },
 
+    getDevice() {
+      common.getDevice();
+    },
+
     showDrawSetting() {
       this.isDrawSetting = !this.isDrawSetting;
     },

+ 16 - 6
src/views/live/live.js

@@ -186,9 +186,7 @@ export function initListener(vue) {
           let streamType = stream.streamType();
           console.log('订阅流成功', streamType);
           stream.show(store.state.user.user_type === 'STUDENT' ? 'live' : 'student', 'contain'); // 将流显示到id为 live 的盒子中
-          if (streamType === 10 || streamType === 1) {
-            vue.connection = true;
-          }
+          vue.connection = true;
         },
         fail: function (err) {
           console.log('订阅流失败', err);
@@ -266,9 +264,7 @@ export function initListener(vue) {
   // 监听通知移除流事件
   rtc.on('stream_removed', function (stream) {
     console.log('监听通知移除流事件');
-    if (stream.streamType() === 10 || stream.streamType() === 1) {
-      vue.connection = false;
-    }
+    vue.connection = false;
   });
 
   // 停止订阅流
@@ -447,6 +443,20 @@ export function playVideo() {
 }
 
 /**
+ * 获取设备列表
+ */
+export function getDevice() {
+  rtc.getDevice({
+    success: function (data) {
+      console.log('获取成功', data);
+    },
+    fail: function (str) {
+      console.log('直播关闭状态或查询直播失败', str);
+    }
+  });
+}
+
+/**
  * @description 推送桌面共享
  */
 export function publishShareStream() {