Browse Source

update 直播

dusenyao 3 years ago
parent
commit
72c6b6200d

+ 18 - 0
.vscode/javascript.code-snippets

@@ -0,0 +1,18 @@
+{
+	// Place your gcls_sys_learn_web 工作区 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
+	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
+	// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
+	// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
+	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
+	// Placeholders with the same ids are connected.
+	// Example:
+	// "Print to console": {
+	// 	"scope": "javascript,typescript",
+	// 	"prefix": "log",
+	// 	"body": [
+	// 		"console.log('$1');",
+	// 		"$2"
+	// 	],
+	// 	"description": "Log output to console"
+	// }
+}

+ 15 - 0
src/api/live.js

@@ -14,3 +14,18 @@ export function CreateEnterLiveRoomSession(data) {
     data
   });
 }
+
+/**
+ * 得到直播间学员列表
+ * @param {Object} data { task_id 任务ID }
+ */
+export function GetLiveRoomStudentList(data) {
+  let params = getRequestParams('live_room-live_room_dispatch-GetLiveRoomStudentList');
+
+  return request({
+    method: 'post',
+    url: process.env.VUE_APP_LearnWebSI,
+    params,
+    data
+  });
+}

+ 1 - 1
src/components/select/SelectCourse.vue

@@ -8,7 +8,7 @@
   >
     <div>
       <el-dropdown trigger="click" placement="top" @command="selectBook">
-        <span class="el-dropdown-link">{{ curBook.book_name }}s</span>
+        <span class="el-dropdown-link">{{ curBook.book_name }}</span>
         <el-dropdown-menu slot="dropdown">
           <el-dropdown-item v-for="item in book_list" :key="item.book_id" :command="item">
             {{ item.book_name }}

+ 11 - 1
src/views/live/index.vue

@@ -98,12 +98,14 @@
 </template>
 
 <script>
+import { GetLiveRoomStudentList } from '@/api/live';
 import * as common from './live';
 
 export default {
   name: 'Live',
   data() {
     return {
+      task_id: this.$route.query.task_id,
       rtc: null,
       roomData: {
         desc: '直播间标题',
@@ -126,7 +128,9 @@ export default {
       chatList: [],
       isDrawSetting: false,
       drawColorList: ['#FF4747', '#343434', '#628EFF', '#FFCA0E'],
-      drawThicknessList: ['1', '3', '5']
+      drawThicknessList: ['1', '3', '5'],
+      // 直播间学员列表
+      student_list: []
     };
   },
   watch: {
@@ -271,6 +275,12 @@ export default {
 
     showDrawSetting() {
       this.isDrawSetting = !this.isDrawSetting;
+    },
+
+    getLiveRoomStudentList() {
+      GetLiveRoomStudentList(this.task_id).then(({ student_list }) => {
+        this.student_list = student_list;
+      });
     }
   }
 };

+ 28 - 26
src/views/live/live.js

@@ -1,4 +1,5 @@
 import { Message } from 'element-ui';
+import store from '@/store';
 
 /**
  * @description WebSDK 实例化对象
@@ -33,13 +34,13 @@ export function publishStream() {
           console.log('更新上麦结果请求成功,此处可处理应用层逻辑', data);
         },
         fail: function (data) {
-          alert('更新上麦结果请求失败:' + JSON.stringify(data));
+          console.log('更新上麦结果请求失败:' + JSON.stringify(data));
         }
       });
     },
     fail: function (str) {
       // 推流失败,更新上麦结果
-      alert(str);
+      console.log('推流失败,更新上麦结果', str);
     }
   });
 }
@@ -90,17 +91,15 @@ export function createLocalStream() {
       console.log('创建本地流成功', stream);
       // 创建本地流成功,将流展示到id为 live 的dom元素盒子中
       stream.show('live');
-      getLiveStat({
-        success: function (data) {
-          // if (!data.started) {
-          //   startLive();
-          // }
-          startLive();
-        },
-        fail: function (str) {
-          startLive();
-        }
-      });
+      publishStream(); // 如果需要立即推流,执行 publish 方法
+      // getLiveStat({
+      //   success: function (data) {
+      //     console.log(data.started);
+      //   },
+      //   fail: function (str) {
+      //     // startLive();
+      //   }
+      // });
     },
     fail: function (data) {
       // 创建本地流失败,应用层处理
@@ -149,13 +148,16 @@ export function initListener(vue) {
   rtc.on('conference_join', () => {
     console.log('加入房间成功');
     // 有监听就是加入房间成功
-    // if (store.state.user.user_type === 'TEACHER') {
-    //   createLocalStream();
-    // }
-    createLocalStream();
+    if (store.state.user.user_type === 'TEACHER') {
+      createLocalStream();
+    }
+    // createLocalStream();
   });
 
+  // 新增订阅流事件
   rtc.on('allow_sub', function (stream) {
+    let streamType = stream.streamType();
+    console.log(streamType);
     if (stream.isMixed()) {
       console.log('是混合流,不订阅');
     } else {
@@ -169,7 +171,7 @@ export function initListener(vue) {
           stream.show('live', 'contain'); // 将流显示到id为 live 的盒子中
         },
         fail: function (err) {
-          console.log(err);
+          console.log('订阅流失败', err);
         }
       });
     }
@@ -281,14 +283,6 @@ export function closeVideo() {
 }
 
 /**
- * @method handsUp
- * @description 申请连麦
- */
-export function handsUp(data) {
-  rtc.handsUp(data);
-}
-
-/**
  * @method pauseAudio
  * @description 关闭本地流声音
  */
@@ -405,6 +399,14 @@ export function invite(uid) {
 }
 
 /**
+ * @method handsUp
+ * @description 申请连麦
+ */
+export function handsUp(data) {
+  rtc.handsUp(data);
+}
+
+/**
  * @description 学生端接受老师的上麦邀请,同意上麦
  */
 export function inviteAccept() {

+ 1 - 1
src/views/teacher/create_course/step_table/NewTask.vue

@@ -289,7 +289,7 @@ export default {
 
           if (teaching_type === 11) {
             let courseware_id_list = [];
-            this.courseForm.courseware_id_list.forEach(item => {
+            this.courseForm.coursewareInfo.forEach(item => {
               courseware_id_list.push(item.id);
             });
             data['courseware_id_list'] = courseware_id_list;

+ 2 - 2
src/views/teacher/main/CurriculaList.vue

@@ -9,7 +9,7 @@
       </div>
       <div class="curricula-search-button">
         <el-select v-if="userType === 'STUDENT'" v-model="teacher_id">
-          <el-option label="请选择" value="" />
+          <el-option label="-请选择-" value="" />
           <el-option
             v-for="item in teacher_list"
             :key="item.teacher_id"
@@ -18,7 +18,7 @@
           />
         </el-select>
         <el-select v-model="finish_status">
-          <el-option label="请选择" :value="-1" />
+          <el-option label="-请选择-" :value="-1" />
           <el-option
             v-for="item in finish_status_list"
             :key="userType === 'TEACHER' ? item.finish_status : item.status"

+ 1 - 1
src/views/teacher/main/TaskList.vue

@@ -110,7 +110,7 @@ export default {
         }).then(({ live_room_sys_user_id, room_id, session_id }) => {
           this.$router.push({
             path: '/live',
-            query: { live_room_sys_user_id, room_id, session_id }
+            query: { live_room_sys_user_id, room_id, session_id, task_id }
           });
         });
       } else {