@@ -76,7 +76,7 @@ @interface TIoTDemoPreviewDeviceVC ()<UITableViewDelegate,UITableViewDataSource>
7676@property (nonatomic , assign ) CFTimeInterval endPlayer;
7777@property (nonatomic , assign ) CFTimeInterval startIpcP2P;
7878@property (nonatomic , assign ) CFTimeInterval endIpcP2P;
79-
79+ @property ( nonatomic , assign ) BOOL is_init_alert;
8080@property (nonatomic , assign ) BOOL is_ijkPlayer_stream; // 通过播放器 还是 通过裸流拉取数据
8181@end
8282
@@ -85,7 +85,7 @@ @implementation TIoTDemoPreviewDeviceVC
8585- (void )viewDidLoad {
8686 [super viewDidLoad ];
8787 // Do any additional setup after loading the view.
88-
88+ _is_init_alert = NO ;
8989 _is_ijkPlayer_stream = YES ;
9090 // 关闭日志
9191// [TIoTCoreXP2PBridge sharedInstance].logEnable = NO;
@@ -220,7 +220,7 @@ - (void)getDeviceStatusWithType:(NSString *)singleType qualityType:(NSString *)q
220220// config.sampleRate = 44100;
221221
222222 // 设置会话 withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionAllowBluetooth
223- // [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDuckOthers error:nil];
223+ // [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord mode:AVAudioSessionModeVoiceChat options:AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth error:nil ];
224224// [[AVAudioSession sharedInstance] setActive:YES error:nil];
225225 [[TIoTCoreXP2PBridge sharedInstance ] sendVoiceToServer: self .deviceName?:@" " channel: channel audioConfig: config];
226226 }
@@ -577,6 +577,8 @@ - (void)clickTalkback:(UIButton *)button {
577577 }else {
578578 self.talkbackIcon .image = [UIImage imageNamed: @" talkback_unselect" ];
579579 [[TIoTCoreXP2PBridge sharedInstance ] stopVoiceToServer ];
580+
581+ [self .player play ];
580582 }
581583
582584 button.selected = !button.selected ;
@@ -996,14 +998,22 @@ - (void)moviePlayBackStateDidChange:(NSNotification*)notification
996998 }
997999
9981000 // 弹框
999- NSString *messageString = [NSString stringWithFormat: @" P2P连接时间: %ld (ms)\n 画面显示时间: %ld (ms)" ,(long )p2pConnectTime,(NSInteger )((self .endPlayer - self .startPlayer)*1000 )];
1000- UIAlertController *alertC = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat: @" 设备名:%@ " ,self .deviceName?:@" " ] message: messageString preferredStyle: (UIAlertControllerStyleAlert)];
1001- UIAlertAction *alertA = [UIAlertAction actionWithTitle: @" 确定" style: (UIAlertActionStyleDefault) handler: ^(UIAlertAction * _Nonnull action) {
1001+ if (!_is_init_alert) {
1002+ NSString *messageString = [NSString stringWithFormat: @" P2P连接时间: %ld (ms)\n 画面显示时间: %ld (ms)" ,(long )p2pConnectTime,(NSInteger )((self .endPlayer - self .startPlayer)*1000 )];
1003+ UIAlertController *alertC = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat: @" 设备名:%@ " ,self .deviceName?:@" " ] message: messageString preferredStyle: (UIAlertControllerStyleAlert)];
1004+ UIAlertAction *alertA = [UIAlertAction actionWithTitle: @" 确定" style: (UIAlertActionStyleDefault) handler: ^(UIAlertAction * _Nonnull action) {
1005+
1006+ }];
10021007
1003- }];
1004-
1005- [alertC addAction: alertA];
1006- [self presentViewController: alertC animated: YES completion: nil ];
1008+ [alertC addAction: alertA];
1009+ [self presentViewController: alertC animated: YES completion: nil ];
1010+
1011+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(1.5 * NSEC_PER_SEC)), dispatch_get_main_queue (), ^{
1012+ [alertC dismissViewControllerAnimated: YES completion: NULL ];
1013+ });
1014+
1015+ _is_init_alert = YES ;
1016+ }
10071017
10081018 break ;
10091019 }
0 commit comments