Sfoglia il codice sorgente

音频小于1s不发送

桂欢 1 anno fa
parent
commit
c922ecad3b

+ 8 - 2
SLAiELTS/SLAiELTS/ViewControllers/MessageVC/SLMessageViewController.m

@@ -60,8 +60,14 @@
     WS(weakSelf);
     self.mikeInputView.nuiSpeechRecognizer.recognizerResultBlock = ^(NSString * _Nonnull text, NSString * _Nonnull voicePath) {
         MessageModel *model = [MessageModel initWithSendText:text isReceive:NO showMike:YES showText:NO isMike:YES voicePath:voicePath];
-        model.toId = weakSelf.friendModel.userId;
-        [weakSelf.chatServiceView.messageView appendMessage:model];
+        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
+            if (model.audioDuration < 1.2) {
+                [ZFToast ShowWithMessage:@"说话时间太短!"];
+            }else {
+                model.toId = weakSelf.friendModel.userId;
+                [weakSelf.chatServiceView.messageView appendMessage:model];
+            }
+        });
     };
     self.mikeInputView.hidden = YES;
     [self.view addSubview:self.mikeInputView];