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(); } } }