@@ -403,6 +403,38 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
403403 player.setMaxPacketNum(2 )
404404 }
405405
406+ private fun restartService (id : String? ) {
407+ when (id) {
408+ " ${device1Info?.productId} /${device1Info?.deviceName} " -> {
409+ threadPool1.submit {
410+ stopDeviceService(device1Info!! , 1 )
411+ device1Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig1) }
412+ }
413+ }
414+
415+ " ${device2Info?.productId} /${device2Info?.deviceName} " -> {
416+ threadPool2.submit {
417+ stopDeviceService(device2Info!! , 2 )
418+ device2Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig2) }
419+ }
420+ }
421+
422+ " ${device3Info?.productId} /${device3Info?.deviceName} " -> {
423+ threadPool3.submit {
424+ stopDeviceService(device3Info!! , 3 )
425+ device3Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig3) }
426+ }
427+ }
428+
429+ " ${device4Info?.productId} /${device4Info?.deviceName} " -> {
430+ threadPool4.submit {
431+ stopDeviceService(device4Info!! , 4 )
432+ device4Info?.let { it1 -> startSingleDeviceTest(it1, xP2PAppConfig4) }
433+ }
434+ }
435+ }
436+ }
437+
406438
407439 // IMediaPlayer.OnInfoListener接口实现
408440 override fun onInfo (p0 : IMediaPlayer ? , p1 : Int , p2 : Int ): Boolean {
@@ -418,8 +450,11 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
418450 }
419451
420452 // XP2PCallback接口实现
421- override fun fail (msg : String? , errorCode : Int ) {
422- Log .e(tag, " XP2P连接失败: $msg , errorCode: $errorCode " )
453+ override fun fail (id : String? , errorCode : Int ) {
454+ Log .e(tag, " XP2P连接失败: $id , errorCode: $errorCode " )
455+ if (- 1011 == errorCode) {
456+ restartService(id)
457+ }
423458 }
424459
425460 override fun commandRequest (id : String? , msg : String? ) {
@@ -433,6 +468,7 @@ class MultiVideoTestActivity : VideoBaseActivity<ActivityMultiVideoTestBinding>(
433468 1003 -> {
434469 // 连接断开,尝试重连
435470 Log .e(tag, " XP2P连接断开,尝试重连" )
471+ restartService(id)
436472 coroutineScope.launch(Dispatchers .Main ) {
437473 Toast .makeText(
438474 this @MultiVideoTestActivity,
0 commit comments