This commit is contained in:
启星
2025-10-30 18:30:45 +08:00
parent aa356202e2
commit c92b8eb910
11 changed files with 297 additions and 87 deletions

View File

@@ -7,6 +7,8 @@
#import "QXRoomChatListView.h"
#import "UIImage+WebP.h"
#import <AVFoundation/AVFoundation.h>
#define messageNoticeColor RGB16(0xCCA882)
#define messageNameColor RGB16(0x00C8FF)
#define messageGiftColor RGB16(0xFFE309)
@@ -51,6 +53,7 @@ NSInteger maxMessageCount = 20;
@property (nonatomic,assign)BOOL isDragging;
@property (nonatomic,strong)UILabel *messageLabel;
@property (nonatomic,strong)UIButton *messageCountBtn;
@property (nonatomic,strong)AVSpeechSynthesizer *synthesizer;
@end
@implementation QXRoomChatListView
@@ -64,6 +67,7 @@ NSInteger maxMessageCount = 20;
}
-(void)initSubviews{
self.synthesizer = [[AVSpeechSynthesizer alloc] init];
[self addSubview:self.tableView];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
@@ -197,6 +201,16 @@ NSInteger maxMessageCount = 20;
// if (self.giftArray.count>maxMessageCount) {
// [self.giftArray removeFirstObject];
// }
#if DEBUG
if (model.messageType == QXRoomChatMessageTypeGift || model.messageType == QXRoomChatMessageTypeSystem) {
AVSpeechUtterance *utterance = [[AVSpeechUtterance alloc] initWithString:model.text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:@"zh-CN"];
utterance.rate = 0.5 ;
utterance.pitchMultiplier = 1.0 ;
utterance.volume = 1.0 ;
[self.synthesizer speakUtterance:utterance];
}
#endif
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:self.dataArray.count - 1 inSection:0];
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationNone];