From 86f6b9d69b9ecf1ed8c0be0e4681bfc8f6350ec7 Mon Sep 17 00:00:00 2001
From: wbin <737436093@qq.com>
Date: Tue, 9 Feb 2021 14:10:38 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=B4=E6=8E=A5=E5=90=AF?=
=?UTF-8?q?=E5=8A=A8=E7=AA=97=E5=8F=A3=EF=BC=8C=E6=B7=BB=E5=8A=A0roomid?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
JianGongYun/App.config | 2 +-
JianGongYun/App.xaml.cs | 1 -
JianGongYun/TRTC/LiveClassroom.cs | 17 ++++++++++-----
JianGongYun/TRTC/Windows/LiveWindow.xaml.cs | 4 ++++
JianGongYun/Views/Login.xaml.cs | 23 +++++++++++++++++----
5 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/JianGongYun/App.config b/JianGongYun/App.config
index f7d7887..413d4d0 100644
--- a/JianGongYun/App.config
+++ b/JianGongYun/App.config
@@ -5,6 +5,6 @@
-
+
diff --git a/JianGongYun/App.xaml.cs b/JianGongYun/App.xaml.cs
index 33aa09c..c44ffeb 100644
--- a/JianGongYun/App.xaml.cs
+++ b/JianGongYun/App.xaml.cs
@@ -13,6 +13,5 @@ namespace JianGongYun
///
public partial class App : Application
{
-
}
}
diff --git a/JianGongYun/TRTC/LiveClassroom.cs b/JianGongYun/TRTC/LiveClassroom.cs
index 9092bc2..d5d9007 100644
--- a/JianGongYun/TRTC/LiveClassroom.cs
+++ b/JianGongYun/TRTC/LiveClassroom.cs
@@ -100,7 +100,7 @@ namespace JianGongYun.TRTC
strRoomId = CurrentClassroomEntity.TeacherId,
role = TRTCRoleType.TRTCRoleAnchor,
streamId = CurrentClassroomEntity.TeacherId,//旁路CDN流名字为教师id
- userDefineRecordId= CurrentClassroomEntity.TeacherId//指定id录制教师
+ userDefineRecordId = CurrentClassroomEntity.TeacherId//指定id录制教师
};
lTRTCCloud.enterRoom(ref roomPars, TRTCAppScene.TRTCAppSceneLIVE);//创建房间
@@ -128,7 +128,7 @@ namespace JianGongYun.TRTC
_RecoderDir = $"{classroomEntity.ClassHead}_{classroomEntity.ClassSubHead}";
- callerWindow.Hide();//隐藏调用窗口
+ callerWindow?.Hide();//隐藏调用窗口
CurrentLiveWindow.Show();
}
@@ -493,7 +493,7 @@ namespace JianGongYun.TRTC
}
}
- Skip1:
+ Skip1:
if (liveWinMode.CameraRunning)//摄像头分享中
{
@@ -521,7 +521,7 @@ namespace JianGongYun.TRTC
}
}
- Skip2:
+ Skip2:
mats.Enqueue(BackgroundFrame.CvtColor(ColorConversionCodes.BGRA2BGR));
Interlocked.Increment(ref runFps);
@@ -712,7 +712,7 @@ namespace JianGongYun.TRTC
{
CurrentLiveWindow = null;
CurrentClassroomEntity = null;
- CallerWindow.Show();//还原调用者窗口
+
lTXDeviceManager.Dispose();
lTXDeviceManager = null;
@@ -721,6 +721,13 @@ namespace JianGongYun.TRTC
ITRTCCloud.destroyTRTCShareInstance();//销毁TRTC实例
lTRTCCloud.Dispose();
lTRTCCloud = null;
+ if (CallerWindow == null)
+ {
+ //关闭程序
+ Application.Current.Shutdown();
+ return;
+ }
+ CallerWindow.Show();//还原调用者窗口
}
diff --git a/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs b/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs
index 0134eb5..83010f7 100644
--- a/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs
+++ b/JianGongYun/TRTC/Windows/LiveWindow.xaml.cs
@@ -170,6 +170,10 @@ namespace JianGongYun.TRTC.Windows
LiveClassroom.StopVideoSub(AfterLiveSubViewWrap);
this.Hide();
+ if (LiveClassroom.CallerWindow == null) {
+ Application.Current.Shutdown();
+ return;
+ }
LiveClassroom.CallerWindow.Show();//还原调用者窗口
}
diff --git a/JianGongYun/Views/Login.xaml.cs b/JianGongYun/Views/Login.xaml.cs
index 5a20cfe..f885528 100644
--- a/JianGongYun/Views/Login.xaml.cs
+++ b/JianGongYun/Views/Login.xaml.cs
@@ -1,6 +1,9 @@
-using AduSkin.Controls.Metro;
+using AduSkin.Controls;
+using AduSkin.Controls.Metro;
+using JianGongYun.TRTC;
using System;
using System.Collections.Generic;
+using System.Configuration;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@@ -22,9 +25,21 @@ namespace JianGongYun.Views
{
InitializeComponent();
BorderBrush = new SolidColorBrush(color: Color.FromRgb(42, 43, 48));
- MainWindow main = new MainWindow();
- main.Show();
- this.Hide();
+ var roomId = ConfigurationManager.AppSettings["RoomId"];
+ if (string.IsNullOrWhiteSpace(roomId))
+ {
+ MessageBox.Show("未配置房间号!","警告", MessageBoxButton.OKCancel,MessageBoxImage.Error);
+ Application.Current.Shutdown();
+ }
+ LiveClassroom.EnterTheClassroom(null,
+ new TRTC.Models.ClassroomEntity
+ {
+ ClassHead = "课程1",
+ ClassSubHead = "章节1",
+ TeacherId = roomId,
+ TeacherName = "王大锤"
+ });
+ this.Close();
}
}
}