@@ -81,8 +81,6 @@ public TRTCMainForm(TRTCLoginForm loginForm)
81
81
InitializeComponent ( ) ;
82
82
83
83
this . Disposed += new EventHandler ( OnDisposed ) ;
84
- // 窗口退出事件监听
85
- this . FormClosing += new FormClosingEventHandler ( OnExitLabelClick ) ;
86
84
87
85
// 初始化数据。
88
86
mLoginForm = loginForm ;
@@ -150,23 +148,17 @@ private void RemoveCustomVideoView(Control parent, string userId, TRTCVideoStrea
150
148
if ( mVideoViews . TryGetValue ( key , out videoView ) )
151
149
{
152
150
videoView . RemoveEngine ( mTRTCCloud ) ;
153
- parent . Controls . Remove ( videoView ) ;
154
151
mVideoViews . Remove ( key ) ;
152
+ parent . Controls . Remove ( videoView ) ;
155
153
}
156
154
}
157
155
158
156
private void OnDisposed ( object sender , EventArgs e )
159
157
{
160
158
// 清理资源
159
+ mTRTCCloud . removeCallback ( this ) ;
160
+ mTRTCCloud . setLogCallback ( null ) ;
161
161
mTRTCCloud = null ;
162
- if ( mCustomCaptureForm != null )
163
- mCustomCaptureForm . Dispose ( ) ;
164
- if ( mDeviceForm != null )
165
- mDeviceForm . Dispose ( ) ;
166
- if ( mDeviceTestForm != null )
167
- mDeviceTestForm . Dispose ( ) ;
168
- if ( mSettingForm != null )
169
- mSettingForm . Dispose ( ) ;
170
162
}
171
163
172
164
private void OnFormLoad ( object sender , EventArgs e )
@@ -473,7 +465,14 @@ public void onError(TXLiteAVError errCode, string errMsg, IntPtr arg)
473
465
public void onExitRoom ( int reason )
474
466
{
475
467
mIsEnterSuccess = false ;
468
+ // 如果进房成功,需要正常退房再关闭窗口,防止资源未清理和释放完毕
469
+ Uninit ( ) ;
476
470
this . Close ( ) ;
471
+ if ( mLoginForm == null )
472
+ {
473
+ mLoginForm = new TRTCLoginForm ( ) ;
474
+ }
475
+ mLoginForm . Show ( ) ;
477
476
}
478
477
479
478
/// <summary>
@@ -513,8 +512,6 @@ private void Uninit()
513
512
mMixStreamVideoMeta . Clear ( ) ;
514
513
mRemoteUsers . Clear ( ) ;
515
514
mPKUsers . Clear ( ) ;
516
- mTRTCCloud . removeCallback ( this ) ;
517
- mTRTCCloud . setLogCallback ( null ) ;
518
515
// 注意:系统混音功能暂时不支持64位系统
519
516
if ( ! Util . IsSys64bit ( ) )
520
517
{
@@ -529,6 +526,7 @@ private void Uninit()
529
526
}
530
527
if ( this . mixTransCodingCheckBox . Checked )
531
528
mTRTCCloud . setMixTranscodingConfig ( null ) ;
529
+
532
530
}
533
531
534
532
/// <summary>
@@ -900,8 +898,6 @@ private void SetVisableInfoView(int pos, bool visable)
900
898
private void OnExitLabelClick ( object sender , EventArgs e )
901
899
{
902
900
// 退出房间
903
- if ( mIsFirstExitRoom ) return ;
904
- mIsFirstExitRoom = true ;
905
901
if ( mBeautyForm != null )
906
902
mBeautyForm . Close ( ) ;
907
903
if ( mDeviceTestForm != null )
@@ -916,22 +912,14 @@ private void OnExitLabelClick(object sender, EventArgs e)
916
912
mDeviceTestForm . Close ( ) ;
917
913
if ( mDeviceForm != null )
918
914
mDeviceForm . Close ( ) ;
919
- Uninit ( ) ;
920
- // 如果进房成功,需要正常退房再关闭窗口,防止资源未清理和释放完毕
921
915
if ( mIsEnterSuccess )
922
916
{
923
917
mTRTCCloud . exitRoom ( ) ;
924
- this . Hide ( ) ;
925
918
}
926
919
else
927
920
{
928
- this . Close ( ) ;
921
+ onExitRoom ( 0 ) ;
929
922
}
930
- if ( mLoginForm == null )
931
- {
932
- mLoginForm = new TRTCLoginForm ( ) ;
933
- }
934
- mLoginForm . Show ( ) ;
935
923
}
936
924
937
925
private void OnSettingLabelClick ( object sender , EventArgs e )
@@ -1327,11 +1315,11 @@ private void OnShareUrlLabelClick(object sender, EventArgs e)
1327
1315
ShowMessage ( "请勾选云端混流选项!" ) ;
1328
1316
return ;
1329
1317
}
1330
- // 计算 CDN 地址(格式: http://[bizid].liveplay.myqcloud.com/live/[bizid]_[streamid] .flv )
1318
+ // 计算 CDN 地址(格式: http://[bizid].liveplay.myqcloud.com/live/sdkappid_roomId_userId_main .flv )
1331
1319
int bizId = GenerateTestUserSig . BIZID ;
1332
- // streamid = MD5 (房间号_用户名_流类型)
1333
- string streamId = Util . MD5 ( String . Format ( "{0}_{1}_{2}" , mRoomId , Util . UTF16To8 ( mUserId ) , "main" ) ) ;
1334
- string shareUrl = String . Format ( "http://{0}.liveplay.myqcloud.com/live/{0}_{ 1}.flv" , bizId , streamId ) ;
1320
+ // streamid = SDKAPPID_房间号_用户名_流类型
1321
+ string streamId = String . Format ( "{0}_{1}_{2}_{3} " , GenerateTestUserSig . SDKAPPID , mRoomId , Util . UTF16To8 ( mUserId ) , "main" ) ;
1322
+ string shareUrl = String . Format ( "http://{0}.liveplay.myqcloud.com/live/{1}.flv" , bizId , streamId ) ;
1335
1323
Log . I ( "播放地址: " + shareUrl ) ;
1336
1324
Clipboard . SetDataObject ( shareUrl ) ;
1337
1325
ShowMessage ( "播放地址:(已复制到剪切板)\n " + shareUrl ) ;
@@ -1763,6 +1751,12 @@ public void onPlayBGMBegin(TXLiteAVError errCode)
1763
1751
public void onPlayBGMComplete ( TXLiteAVError errCode )
1764
1752
{
1765
1753
Log . I ( String . Format ( "onPlayBGMComplete : errCode = {0}" , errCode ) ) ;
1754
+ if ( this . IsHandleCreated )
1755
+ this . BeginInvoke ( new Action ( ( ) =>
1756
+ {
1757
+ if ( mDeviceTestForm != null )
1758
+ mDeviceTestForm . OnPlayBGMComplete ( errCode ) ;
1759
+ } ) ) ;
1766
1760
}
1767
1761
1768
1762
public void onPlayBGMProgress ( uint progressMS , uint durationMS )
@@ -1820,6 +1814,12 @@ public void onSetMixTranscodingConfig(int errCode, string errMsg)
1820
1814
public void onAudioEffectFinished ( int effectId , int code )
1821
1815
{
1822
1816
Log . I ( String . Format ( "onAudioEffectFinished : effectId = {0}, code = {1}" , effectId , code ) ) ;
1817
+ if ( this . IsHandleCreated )
1818
+ this . BeginInvoke ( new Action ( ( ) =>
1819
+ {
1820
+ if ( mDeviceTestForm != null )
1821
+ mDeviceTestForm . onAudioEffectFinished ( effectId , code ) ;
1822
+ } ) ) ;
1823
1823
}
1824
1824
1825
1825
public void onSpeedTest ( TRTCSpeedTestResult currentResult , uint finishedCount , uint totalCount )
0 commit comments