|
@@ -30,6 +30,31 @@ export function unSubscribeStream(unSubStream) {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+function createLocalStream(vue) {
|
|
|
+ rtc.createLocalStream({
|
|
|
+ streamName: 'picture',
|
|
|
+ createData: createData(),
|
|
|
+ success(stream) {
|
|
|
+ vue.localStream = true;
|
|
|
+ console.log('创建本地流成功', stream);
|
|
|
+ vue.hasVideo = stream.hasVideo;
|
|
|
+ vue.hasAudio = stream.hasAudio;
|
|
|
+ // 创建本地流成功,将流展示到id为 student 的dom元素盒子中
|
|
|
+ stream.show('group-local');
|
|
|
+ publishStream('picture'); // 如果需要立即推流,执行 publish 方法
|
|
|
+ },
|
|
|
+ fail(data) {
|
|
|
+ vue.localStream = false;
|
|
|
+ console.log('创建本地流失败,应用层处理', data);
|
|
|
+ // 创建本地流失败,应用层处理
|
|
|
+ Message({
|
|
|
+ type: 'error',
|
|
|
+ message: '创建本地流失败:' + data
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 初始化监听事件
|
|
|
*/
|
|
@@ -53,38 +78,20 @@ export function initListener(vue) {
|
|
|
// 教师 必须在加入房间成功的事件回调里创建本地流
|
|
|
rtc.on('conference_join', () => {
|
|
|
console.log('加入房间成功');
|
|
|
- rtc.handsUp({
|
|
|
- success: str => {
|
|
|
- console.log('举手成功', str);
|
|
|
- console.log('创建本地流推流');
|
|
|
-
|
|
|
- rtc.createLocalStream({
|
|
|
- streamName: 'picture',
|
|
|
- createData: createData(),
|
|
|
- success(stream) {
|
|
|
- vue.localStream = true;
|
|
|
- console.log('创建本地流成功', stream);
|
|
|
- vue.hasVideo = stream.hasVideo;
|
|
|
- vue.hasAudio = stream.hasAudio;
|
|
|
- // 创建本地流成功,将流展示到id为 student 的dom元素盒子中
|
|
|
- stream.show('group-local');
|
|
|
- publishStream('picture'); // 如果需要立即推流,执行 publish 方法
|
|
|
- },
|
|
|
- fail(data) {
|
|
|
- vue.localStream = false;
|
|
|
- console.log('创建本地流失败,应用层处理', data);
|
|
|
- // 创建本地流失败,应用层处理
|
|
|
- Message({
|
|
|
- type: 'error',
|
|
|
- message: '创建本地流失败:' + data
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- fail: data => {
|
|
|
- console.log('举手失败', data);
|
|
|
- }
|
|
|
- });
|
|
|
+ if (vue.studentSelf.is_teacher_role_in_room === 'true') {
|
|
|
+ rtc.handsUp({
|
|
|
+ success: str => {
|
|
|
+ console.log('举手成功', str);
|
|
|
+ console.log('创建本地流推流');
|
|
|
+ createLocalStream(vue);
|
|
|
+ },
|
|
|
+ fail: data => {
|
|
|
+ console.log('举手失败', data);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ createLocalStream(vue);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
rtc.on('conference_join_failed', err => {
|