dusenyao 3 năm trước cách đây
mục cha
commit
b4dd6389f1

+ 23 - 23
src/views/live/student/group.js

@@ -51,6 +51,29 @@ export function initListener(vue) {
     rtc.handsUp({
       success: str => {
         console.log('举手成功', str);
+        console.log('创建本地流推流');
+        const createData = {
+          video: true,
+          audio: true
+        };
+        rtc.createLocalStream({
+          streamName: 'picture',
+          createData,
+          success: function (stream) {
+            console.log('创建本地流成功', stream);
+            // 创建本地流成功,将流展示到id为 student 的dom元素盒子中
+            stream.show('group-local');
+            publishStream('picture'); // 如果需要立即推流,执行 publish 方法
+          },
+          fail: function (data) {
+            console.log('创建本地流失败,应用层处理', data);
+            // 创建本地流失败,应用层处理
+            Message({
+              type: 'error',
+              message: '创建本地流失败:' + data
+            });
+          }
+        });
       },
       fail: data => {
         console.log('举手失败', data);
@@ -190,30 +213,7 @@ export function initListener(vue) {
   });
 
   rtc.on('createLocalStream', () => {
-    // 创建本地流推流
     console.log('创建本地流推流');
-    const createData = {
-      video: true,
-      audio: true
-    };
-    rtc.createLocalStream({
-      streamName: 'picture',
-      createData,
-      success: function (stream) {
-        console.log('创建本地流成功', stream);
-        // 创建本地流成功,将流展示到id为 student 的dom元素盒子中
-        stream.show('group-local');
-        publishStream('picture'); // 如果需要立即推流,执行 publish 方法
-      },
-      fail: function (data) {
-        console.log('创建本地流失败,应用层处理', data);
-        // 创建本地流失败,应用层处理
-        Message({
-          type: 'error',
-          message: '创建本地流失败:' + data
-        });
-      }
-    });
   });
 
   /**

+ 9 - 1
src/views/live/student/group.vue

@@ -190,7 +190,15 @@ export default {
   beforeDestroy() {
     clearInterval(this.timer);
     StudentExitLiveRoom({ task_id: this.task_id, room_user_id: this.room_user_id });
-    common.closeVideo('picture');
+    common.handsDown({
+      uid: this.room_user_id,
+      success: str => {
+        console.log('下麦成功', str);
+      },
+      fail: data => {
+        console.log('下麦失败', data);
+      }
+    });
     this.streamList.forEach(item => {
       common.unSubscribeStream(item);
     });

+ 4 - 1
src/views/live/student/index.vue

@@ -134,7 +134,8 @@ import {
   GetCurMaterialSent,
   GetLiveRoomInfo,
   GetGroupStatus,
-  GetMyGroupInfo_Student
+  GetMyGroupInfo_Student,
+  CreateEnterLiveRoomSession
 } from '@/api/live';
 import CurMaterial from '@/components/live/CurMaterial.vue';
 import * as common from './live';
@@ -227,6 +228,8 @@ export default {
     }
   },
   created() {
+    CreateEnterLiveRoomSession({ task_id: this.task_id });
+
     GetGroupStatus({ task_id: this.task_id }).then(({ is_enable_group }) => {
       if (is_enable_group === 'true') {
         this.getMyGroupInfo_Student();