Skip to content

Commit 1844b3c

Browse files
author
mengyaoyao
committed
视频消息部分设定
1 parent 275fc9c commit 1844b3c

File tree

17 files changed

+1096
-261
lines changed

17 files changed

+1096
-261
lines changed

CocoaAsyncSocket_TCP.xcodeproj/project.pbxproj

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
B85F3A4A1EC9C9C600B2EA9E /* NSString+extension.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A041EC9C9C600B2EA9E /* NSString+extension.m */; };
4343
B85F3A4B1EC9C9C600B2EA9E /* UIImage+colorImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A061EC9C9C600B2EA9E /* UIImage+colorImage.m */; };
4444
B85F3A4C1EC9C9C600B2EA9E /* UIImageView+SDWebImage.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A081EC9C9C600B2EA9E /* UIImageView+SDWebImage.m */; };
45-
B85F3A4D1EC9C9C600B2EA9E /* MYCoreTextLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A0E1EC9C9C600B2EA9E /* MYCoreTextLabel.m */; };
46-
B85F3A4E1EC9C9C600B2EA9E /* MYCoretextResultTool.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A101EC9C9C600B2EA9E /* MYCoretextResultTool.m */; };
47-
B85F3A4F1EC9C9C600B2EA9E /* MYSubCoretextResult.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A121EC9C9C600B2EA9E /* MYSubCoretextResult.m */; };
4845
B85F3A501EC9C9C600B2EA9E /* ChatNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A151EC9C9C600B2EA9E /* ChatNavigationController.m */; };
4946
B85F3A511EC9C9C600B2EA9E /* LocalConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A191EC9C9C600B2EA9E /* LocalConnection.m */; };
5047
B85F3A521EC9C9C600B2EA9E /* FSMEngine.m in Sources */ = {isa = PBXBuildFile; fileRef = B85F3A1D1EC9C9C600B2EA9E /* FSMEngine.m */; };
@@ -82,6 +79,9 @@
8279
B862F5B51ECE7EB300B40BA1 /* ChatEmotions.plist in Resources */ = {isa = PBXBuildFile; fileRef = B862F5B41ECE7EB300B40BA1 /* ChatEmotions.plist */; };
8380
B8661AAA1ECD998E0022753D /* UIImageView+GIF.m in Sources */ = {isa = PBXBuildFile; fileRef = B8661AA91ECD998E0022753D /* UIImageView+GIF.m */; };
8481
B89E046A1ED03F23000863F1 /* UIImage+photoPicker.m in Sources */ = {isa = PBXBuildFile; fileRef = B89E04691ED03F23000863F1 /* UIImage+photoPicker.m */; };
82+
B8A04C8D1F06002100882727 /* MYCoreTextLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = B8A04C881F06002100882727 /* MYCoreTextLabel.m */; };
83+
B8A04C8E1F06002100882727 /* MYCoretextResultTool.m in Sources */ = {isa = PBXBuildFile; fileRef = B8A04C8A1F06002100882727 /* MYCoretextResultTool.m */; };
84+
B8A04C8F1F06002100882727 /* MYSubCoretextResult.m in Sources */ = {isa = PBXBuildFile; fileRef = B8A04C8C1F06002100882727 /* MYSubCoretextResult.m */; };
8585
B8EEC0C91ED47E2800F52E79 /* ChatConfigModel.m in Sources */ = {isa = PBXBuildFile; fileRef = B8EEC0C81ED47E2800F52E79 /* ChatConfigModel.m */; };
8686
E1527204E4A6C66E20ABAB19 /* Pods_CocoaAsyncSocket_TCP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24AA3076491D2596209CE424 /* Pods_CocoaAsyncSocket_TCP.framework */; };
8787
/* End PBXBuildFile section */
@@ -178,12 +178,6 @@
178178
B85F3A081EC9C9C600B2EA9E /* UIImageView+SDWebImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+SDWebImage.m"; sourceTree = "<group>"; };
179179
B85F3A091EC9C9C600B2EA9E /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Config.h; sourceTree = "<group>"; };
180180
B85F3A0A1EC9C9C600B2EA9E /* Constant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Constant.h; sourceTree = "<group>"; };
181-
B85F3A0D1EC9C9C600B2EA9E /* MYCoreTextLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYCoreTextLabel.h; sourceTree = "<group>"; };
182-
B85F3A0E1EC9C9C600B2EA9E /* MYCoreTextLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCoreTextLabel.m; sourceTree = "<group>"; };
183-
B85F3A0F1EC9C9C600B2EA9E /* MYCoretextResultTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYCoretextResultTool.h; sourceTree = "<group>"; };
184-
B85F3A101EC9C9C600B2EA9E /* MYCoretextResultTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCoretextResultTool.m; sourceTree = "<group>"; };
185-
B85F3A111EC9C9C600B2EA9E /* MYSubCoretextResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYSubCoretextResult.h; sourceTree = "<group>"; };
186-
B85F3A121EC9C9C600B2EA9E /* MYSubCoretextResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYSubCoretextResult.m; sourceTree = "<group>"; };
187181
B85F3A141EC9C9C600B2EA9E /* ChatNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatNavigationController.h; sourceTree = "<group>"; };
188182
B85F3A151EC9C9C600B2EA9E /* ChatNavigationController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatNavigationController.m; sourceTree = "<group>"; };
189183
B85F3A181EC9C9C600B2EA9E /* LocalConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalConnection.h; sourceTree = "<group>"; };
@@ -256,6 +250,12 @@
256250
B8661AA91ECD998E0022753D /* UIImageView+GIF.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImageView+GIF.m"; sourceTree = "<group>"; };
257251
B89E04681ED03F23000863F1 /* UIImage+photoPicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+photoPicker.h"; sourceTree = "<group>"; };
258252
B89E04691ED03F23000863F1 /* UIImage+photoPicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+photoPicker.m"; sourceTree = "<group>"; };
253+
B8A04C871F06002100882727 /* MYCoreTextLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYCoreTextLabel.h; sourceTree = "<group>"; };
254+
B8A04C881F06002100882727 /* MYCoreTextLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCoreTextLabel.m; sourceTree = "<group>"; };
255+
B8A04C891F06002100882727 /* MYCoretextResultTool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYCoretextResultTool.h; sourceTree = "<group>"; };
256+
B8A04C8A1F06002100882727 /* MYCoretextResultTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYCoretextResultTool.m; sourceTree = "<group>"; };
257+
B8A04C8B1F06002100882727 /* MYSubCoretextResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MYSubCoretextResult.h; sourceTree = "<group>"; };
258+
B8A04C8C1F06002100882727 /* MYSubCoretextResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MYSubCoretextResult.m; sourceTree = "<group>"; };
259259
B8EEC0C71ED47E2800F52E79 /* ChatConfigModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChatConfigModel.h; sourceTree = "<group>"; };
260260
B8EEC0C81ED47E2800F52E79 /* ChatConfigModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChatConfigModel.m; sourceTree = "<group>"; };
261261
/* End PBXFileReference section */
@@ -482,25 +482,12 @@
482482
B85F3A0B1EC9C9C600B2EA9E /* Helper */ = {
483483
isa = PBXGroup;
484484
children = (
485+
B8A04C861F06002100882727 /* MYCoreTextLabel */,
485486
B816A1B91ED040A20024859F /* TZImagePickerController */,
486-
B85F3A0C1EC9C9C600B2EA9E /* MYCoreTextLabel */,
487487
);
488488
path = Helper;
489489
sourceTree = "<group>";
490490
};
491-
B85F3A0C1EC9C9C600B2EA9E /* MYCoreTextLabel */ = {
492-
isa = PBXGroup;
493-
children = (
494-
B85F3A0D1EC9C9C600B2EA9E /* MYCoreTextLabel.h */,
495-
B85F3A0E1EC9C9C600B2EA9E /* MYCoreTextLabel.m */,
496-
B85F3A0F1EC9C9C600B2EA9E /* MYCoretextResultTool.h */,
497-
B85F3A101EC9C9C600B2EA9E /* MYCoretextResultTool.m */,
498-
B85F3A111EC9C9C600B2EA9E /* MYSubCoretextResult.h */,
499-
B85F3A121EC9C9C600B2EA9E /* MYSubCoretextResult.m */,
500-
);
501-
path = MYCoreTextLabel;
502-
sourceTree = "<group>";
503-
};
504491
B85F3A131EC9C9C600B2EA9E /* Navigation */ = {
505492
isa = PBXGroup;
506493
children = (
@@ -670,6 +657,19 @@
670657
path = ChatModel;
671658
sourceTree = "<group>";
672659
};
660+
B8A04C861F06002100882727 /* MYCoreTextLabel */ = {
661+
isa = PBXGroup;
662+
children = (
663+
B8A04C871F06002100882727 /* MYCoreTextLabel.h */,
664+
B8A04C881F06002100882727 /* MYCoreTextLabel.m */,
665+
B8A04C891F06002100882727 /* MYCoretextResultTool.h */,
666+
B8A04C8A1F06002100882727 /* MYCoretextResultTool.m */,
667+
B8A04C8B1F06002100882727 /* MYSubCoretextResult.h */,
668+
B8A04C8C1F06002100882727 /* MYSubCoretextResult.m */,
669+
);
670+
path = MYCoreTextLabel;
671+
sourceTree = "<group>";
672+
};
673673
CBB7B1986CB029097EB5B82F /* Frameworks */ = {
674674
isa = PBXGroup;
675675
children = (
@@ -878,9 +878,10 @@
878878
files = (
879879
B85F3A7C1EC9C9DE00B2EA9E /* ChatFileCell.m in Sources */,
880880
B85F3A801EC9C9DE00B2EA9E /* ChatVideoCell.m in Sources */,
881+
B8A04C8E1F06002100882727 /* MYCoretextResultTool.m in Sources */,
881882
B85F39F61EC9C9BD00B2EA9E /* AppDelegate.m in Sources */,
882883
B85F3A8D1EC9C9E400B2EA9E /* ChatUtil.m in Sources */,
883-
B85F3A4F1EC9C9C600B2EA9E /* MYSubCoretextResult.m in Sources */,
884+
B8A04C8F1F06002100882727 /* MYSubCoretextResult.m in Sources */,
884885
B85F3A4B1EC9C9C600B2EA9E /* UIImage+colorImage.m in Sources */,
885886
B85F39F51EC9C9BD00B2EA9E /* AppDelegate+main.m in Sources */,
886887
B816A1D51ED040A20024859F /* NSBundle+TZImagePicker.m in Sources */,
@@ -906,11 +907,11 @@
906907
B816A1D61ED040A20024859F /* TZAssetCell.m in Sources */,
907908
B85F3A551EC9C9C600B2EA9E /* ReachStateLoading.m in Sources */,
908909
B8661AAA1ECD998E0022753D /* UIImageView+GIF.m in Sources */,
910+
B8A04C8D1F06002100882727 /* MYCoreTextLabel.m in Sources */,
909911
B85F3A491EC9C9C600B2EA9E /* NSDate+extension.m in Sources */,
910912
B816A1D81ED040A20024859F /* TZGifPhotoPreviewController.m in Sources */,
911913
B85F3A621EC9C9C600B2EA9E /* ChatViewController.m in Sources */,
912914
B816A1E21ED040A20024859F /* UIView+Layout.m in Sources */,
913-
B85F3A4E1EC9C9C600B2EA9E /* MYCoretextResultTool.m in Sources */,
914915
B85F3A5E1EC9C9C600B2EA9E /* ChatTabbar.m in Sources */,
915916
B85F3A5A1EC9C9C600B2EA9E /* PingFoundation.m in Sources */,
916917
B816A1DF1ED040A20024859F /* TZPhotoPreviewController.m in Sources */,
@@ -924,7 +925,6 @@
924925
B85F3A5C1EC9C9C600B2EA9E /* README.md in Sources */,
925926
B85F3A531EC9C9C600B2EA9E /* FSMStateUtil.m in Sources */,
926927
B85F39BF1EC9C95100B2EA9E /* main.m in Sources */,
927-
B85F3A4D1EC9C9C600B2EA9E /* MYCoreTextLabel.m in Sources */,
928928
B816A1DA1ED040A20024859F /* TZImageManager.m in Sources */,
929929
B85F3A501EC9C9C600B2EA9E /* ChatNavigationController.m in Sources */,
930930
B816A1DE1ED040A20024859F /* TZPhotoPreviewCell.m in Sources */,

CocoaAsyncSocket_TCP/ChatHandler/ChatHandler.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ - (void)sendTextMessage:(ChatModel *)textModel
368368
ChatModel *reply = [[ChatModel alloc]init];
369369
ChatContentModel *content = [[ChatContentModel alloc]init];
370370
reply.content = content;
371-
reply.content.text = @"收到文本内容";
371+
reply.content.text = @"我已经收到文本内容,图文混排网址www.baidu.com,还有我的邮箱是mengyao_block@outlook.com , 手机号是13912345678 , 都可以设置成可点击的哈";
372372
reply.messageType = Message_Normal;
373373
reply.contenType = Content_Text;
374374
reply.toUserID = textModel.fromUserID;

CocoaAsyncSocket_TCP/ChatHandler/ChatRecord/RecordUtil/Mp3Recorder.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
@protocol Mp3RecorderDelegate <NSObject>
1212

13+
@optional
1314
- (void)failRecord;
1415

1516
- (void)beginConvert;
1617

18+
@required
1719
- (void)endConvertWithData:(NSData *)voiceData seconds:(NSTimeInterval)time;
1820

1921
@end

CocoaAsyncSocket_TCP/ChatHandler/ChatUtil.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ typedef void(^videoModelCallback)(ChatModel *videoModel);
1515

1616
//消息高度计算
1717
+ (CGFloat)heightForMessage:(ChatModel *)currentChatmodel premodel:(ChatModel *)premodel;
18-
1918
//初始化文本消息模型
2019
+ (ChatModel *)initTextMessage:(NSString *)text config:(ChatModel *)config;
2120
//初始化语音消息模型
@@ -24,5 +23,9 @@ typedef void(^videoModelCallback)(ChatModel *videoModel);
2423
+ (NSArray<ChatModel *> *)initPicMessage:(NSArray<ChatAlbumModel *> *)pics config:(ChatModel *)config;
2524
//初始化视频消息模型
2625
+ (void)initVideoMessage:(ChatAlbumModel *)video config:(ChatModel *)config videoCallback:(videoModelCallback)callback;
26+
//b - kb -M 大小转换
27+
+ (NSString *)dataSize:(ChatModel *)chatModel;
28+
//时间戳转换时间格式
29+
+ (NSString *)videoDurationWithSeconds:(long long int)duration;
2730

2831
@end

CocoaAsyncSocket_TCP/ChatHandler/ChatUtil.m

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ + (void)initVideoMessage:(ChatAlbumModel *)video config:(ChatModel *)config vide
274274
ChatModel *videoModel = [self creatMessageModel:config];
275275
videoModel.contenType = Content_Video;
276276
videoModel.content.fileName = video.name;
277+
videoModel.content.picSize = video.videoCoverImg.size;
277278

278279
//异步存储
279280
dispatch_async(dispatch_get_global_queue(0, 0), ^{
@@ -313,8 +314,58 @@ + (void)initVideoMessage:(ChatAlbumModel *)video config:(ChatModel *)config vide
313314

314315

315316

317+
#pragma mark - data大小转换
318+
+ (NSString *)dataSize:(ChatModel *)chatModel
319+
{
320+
long long int size = chatModel.content.fileSize.longLongValue;
321+
if (size<1024) {
322+
return [NSString stringWithFormat:@"%lldb",size];
323+
324+
}else if (size>1024 && size < 1024 *1024) {
325+
326+
return [NSString stringWithFormat:@"%.1fk",(CGFloat)(1.0 *size/1024)];
327+
328+
}else if(size >1024 && size< 1024*1024*1024){
329+
330+
return [NSString stringWithFormat:@"%.1fM",(CGFloat)(1.0 *size/1024/1024)];
331+
}else{
332+
333+
return [NSString stringWithFormat:@"%.1fG",(CGFloat)(1.0 *size/1024/1024/1024)];
334+
}
335+
}
316336

317-
337+
#pragma mark - 时间戳转换成世界
338+
+ (NSString *)videoDurationWithSeconds:(long long int)duration
339+
{
340+
//60秒以内
341+
if (duration == 0) {
342+
return @"00:00:00";
343+
}else if (duration < 60) {
344+
return [NSString stringWithFormat:@"%@:%@:%lld",@"00",@"00",duration]; // 00:00
345+
}else if (duration<3600){ //一小时内
346+
NSString *hourStr = @"00:"; //小时 //00:00:00
347+
NSString *minitesStr = [NSString stringWithFormat:@"%02lld:",duration/60]; //分钟 8
348+
NSString *secondsStr = [NSString stringWithFormat:@"%02lld",duration%60]; // 0
349+
return [[hourStr stringByAppendingString:minitesStr]stringByAppendingString:secondsStr];
350+
}else{ //大于一小时
351+
352+
NSString *hourStr = [NSString stringWithFormat:@"%02lld:",duration/3600]; //小时
353+
354+
NSInteger lastSeconds = duration%3600; //余下的秒数
355+
if (lastSeconds > 60) { //余下大于一分钟
356+
357+
NSString *minitesStr = [NSString stringWithFormat:@"%02ld:",lastSeconds/60];
358+
NSInteger seconds = lastSeconds%60;
359+
NSString *secondsStr = [NSString stringWithFormat:@"%02ld",(long)seconds];
360+
return [[hourStr stringByAppendingString:minitesStr]stringByAppendingString:secondsStr];
361+
}else{
362+
363+
NSString *minitesStr = @"00:";
364+
NSString *secondsStr = [NSString stringWithFormat:@"%02ld",(long)lastSeconds];
365+
return [[hourStr stringByAppendingString:minitesStr]stringByAppendingString:secondsStr];
366+
}
367+
}
368+
}
318369

319370

320371

CocoaAsyncSocket_TCP/Comon/.DS_Store

0 Bytes
Binary file not shown.

CocoaAsyncSocket_TCP/Comon/Category/UIImage+photoPicker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ typedef void(^videoBaseInfoCallback)(ChatAlbumModel *videoModel);
2929
/**
3030
获取选中的视频
3131
*/
32-
+ (void)openPhotoPickerGetVideo:(videoBaseInfoCallback)callback target:(UIViewController *)target cacheDirectory:(NSString *)basePath;
32+
+ (void)openPhotoPickerGetVideo:(videoBaseInfoCallback)callback target:(UIViewController *)target;
3333

3434
@end
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)