Skip to content

Commit 89ca76d

Browse files
committed
change videoMessage
1 parent f6f9346 commit 89ca76d

File tree

6 files changed

+61
-20
lines changed

6 files changed

+61
-20
lines changed

ios/RNNeteaseIm/RNNeteaseIm.xcodeproj/xcuserdata/Dowin.xcuserdatad/xcschemes/xcschememanagement.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>RNNeteaseIm.xcscheme</key>
88
<dict>
99
<key>orderHint</key>
10-
<integer>15</integer>
10+
<integer>7</integer>
1111
</dict>
1212
</dict>
1313
<key>SuppressBuildableAutocreation</key>

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef void(^Errors)(id erro);
3434
//发送音频
3535
-(void)sendAudioMessage:( NSString *)file duration:( NSString *)duration;
3636
//发送视频
37-
-(void)sendTextMessage:( NSString *)path duration:( NSString *)duration width:( NSString *)width height:( NSString *)height displayName:( NSString *)displayName;
37+
-(void)sendVideoMessage:( NSString *)path duration:( NSString *)duration width:( NSString *)width height:( NSString *)height displayName:( NSString *)displayName;
3838
//发送自定义消息
3939
-(void)sendCustomMessage:(NSDictionary *)dataDict;
4040
//发送地理位置消息

ios/RNNeteaseIm/RNNeteaseIm/ConversationViewController.m

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#import "ContactViewController.h"
1313
#import "NIMKitLocationPoint.h"
1414
#import <AVFoundation/AVFoundation.h>
15+
//#import "NIMKitMediaFetcher.h"
16+
1517
#define NTESNotifyID @"id"
1618
#define NTESCustomContent @"content"
1719

@@ -28,6 +30,7 @@ @interface ConversationViewController ()<NIMMediaManagerDelegate,NIMMediaManager
2830
}
2931
@property (nonatomic,strong) AVAudioPlayer *player; //播放提示音
3032
@property (nonatomic,strong) AVAudioPlayer *redPacketPlayer; //播放提示音
33+
//@property (nonatomic,strong) NIMKitMediaFetcher *mediaFetcher;
3134

3235
@end
3336

@@ -63,6 +66,14 @@ - (instancetype)init {
6366
return self;
6467
}
6568

69+
//- (NIMKitMediaFetcher *)mediaFetcher
70+
//{
71+
// if (!_mediaFetcher) {
72+
// _mediaFetcher = [[NIMKitMediaFetcher alloc] init];
73+
// }
74+
// return _mediaFetcher;
75+
//}
76+
6677
-(void)startSession:(NSString *)sessionID withType:(NSString *)type{
6778
_sessionID = sessionID;
6879
_type = type;
@@ -204,13 +215,18 @@ -(NSMutableArray *)setTimeArr:(NSArray *)messageArr{
204215
[dic setObject:@"video" forKey:@"msgType"];
205216
NIMVideoObject *object = message.messageObject;
206217

207-
[dic setObject:[NSString stringWithFormat:@"%@",object.url ] forKey:@"url"];
218+
[dic setObject:[NSString stringWithFormat:@"%@",object.url ] forKey:@"videoUrl"];
208219
[dic setObject:[NSString stringWithFormat:@"%@", object.displayName ] forKey:@"displayName"];
209220
[dic setObject:[NSString stringWithFormat:@"%@", object.coverUrl ] forKey:@"coverUrl"];
210221
[dic setObject:[NSString stringWithFormat:@"%f",object.coverSize.height ] forKey:@"coverSizeHeight"];
211222
[dic setObject:[NSString stringWithFormat:@"%f", object.coverSize.width ] forKey:@"coverSizeWidth"];
212223
[dic setObject:[NSString stringWithFormat:@"%ld",object.duration ] forKey:@"duration"];
213224
[dic setObject:[NSString stringWithFormat:@"%lld",object.fileLength] forKey:@"fileLength"];
225+
NSMutableDictionary *videoObj = [NSMutableDictionary dictionary];
226+
[videoObj setObject:[NSString stringWithFormat:@"%@",object.url ] forKey:@"videoUrl"];
227+
[videoObj setObject:[NSString stringWithFormat:@"%@", object.coverUrl ] forKey:@"coverUrl"];
228+
[dic setObject:videoObj forKey:@"extend"];
229+
/*
214230
if([[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]){
215231
[dic setObject:[NSString stringWithFormat:@"%@",object.coverPath] forKey:@"coverPath"];
216232
}else{
@@ -220,7 +236,7 @@ -(NSMutableArray *)setTimeArr:(NSArray *)messageArr{
220236
[dic setObject:[NSString stringWithFormat:@"%@",object.coverPath] forKey:@"coverPath"];
221237
}
222238
}];
223-
}
239+
}*/
224240
if ([[NSFileManager defaultManager] fileExistsAtPath:object.path]) {
225241
[dic setObject:[NSString stringWithFormat:@"%@",object.path] forKey:@"mediaPath"];
226242
}else{
@@ -230,7 +246,7 @@ -(NSMutableArray *)setTimeArr:(NSArray *)messageArr{
230246
[dic setObject:[NSString stringWithFormat:@"%@",object.path] forKey:@"mediaPath"];
231247
}
232248
} progress:^(float progress) {
233-
NSLog(@"下载进度%.f",progress);
249+
NSLog(@"视频下载进度%f",progress);
234250
}];
235251
}
236252
}else if(message.messageType == NIMMessageTypeLocation){
@@ -409,18 +425,22 @@ -(void)sendImageMessages:( NSString *)path displayName:( NSString *)displayNa
409425
}
410426

411427
//发送视频
412-
-(void)sendTextMessage:( NSString *)path duration:( NSString *)duration width:( NSString *)width height:( NSString *)height displayName:( NSString *)displayName{
413-
NIMMessage *message;
414-
// if (image) {
415-
// message = [NIMMessageMaker msgWithImage:image];
416-
// }else{
417-
message = [NIMMessageMaker msgWithVideo:path andeSession:_session];
418-
// }
419-
if ([self isFriendToSendMessage:message]) {
420-
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:_session error:nil];
428+
-(void)sendVideoMessage:( NSString *)path duration:( NSString *)duration width:( NSString *)width height:( NSString *)height displayName:( NSString *)displayName{
429+
// __weak typeof(self) weakSelf = self;
430+
// [self.mediaFetcher fetchMediaFromCamera:^(NSString *path, UIImage *image) {
431+
NIMMessage *message;
432+
// if (image) {
433+
// message = [NIMMessageMaker msgWithImage:image andeSession:_session];
434+
// }else{
435+
if ([path hasPrefix:@"file:///private"]) {
436+
path = [path stringByReplacingOccurrencesOfString:@"file:///private" withString:@""];
421437
}
422-
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:_session error:nil];
423-
438+
message = [NIMMessageMaker msgWithVideo:path andeSession:_session];
439+
// }
440+
if ([self isFriendToSendMessage:message]) {
441+
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:_session error:nil];
442+
}
443+
// }];
424444
}
425445

426446
//发送自定义消息
@@ -882,13 +902,18 @@ -(void)refrashMessage:(NIMMessage *)message From:(NSString *)from {
882902
[dic2 setObject:@"video" forKey:@"msgType"];
883903
NIMVideoObject *object = message.messageObject;
884904

885-
[dic2 setObject:[NSString stringWithFormat:@"%@",object.url ] forKey:@"url"];
905+
[dic2 setObject:[NSString stringWithFormat:@"%@",object.url ] forKey:@"videoUrl"];
886906
[dic2 setObject:[NSString stringWithFormat:@"%@", object.displayName ] forKey:@"displayName"];
887907
[dic2 setObject:[NSString stringWithFormat:@"%@", object.coverUrl ] forKey:@"coverUrl"];
888908
[dic2 setObject:[NSString stringWithFormat:@"%f",object.coverSize.height ] forKey:@"coverSizeHeight"];
889909
[dic2 setObject:[NSString stringWithFormat:@"%f", object.coverSize.width ] forKey:@"coverSizeWidth"];
890910
[dic2 setObject:[NSString stringWithFormat:@"%ld",object.duration ] forKey:@"duration"];
891911
[dic2 setObject:[NSString stringWithFormat:@"%lld",object.fileLength] forKey:@"fileLength"];
912+
NSMutableDictionary *videoObj = [NSMutableDictionary dictionary];
913+
[videoObj setObject:[NSString stringWithFormat:@"%@",object.url ] forKey:@"videoUrl"];
914+
[videoObj setObject:[NSString stringWithFormat:@"%@", object.coverUrl ] forKey:@"coverUrl"];
915+
[dic2 setObject:videoObj forKey:@"extend"];
916+
/*
892917
if([[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]){
893918
[dic2 setObject:[NSString stringWithFormat:@"%@",object.coverPath] forKey:@"coverPath"];
894919
}else{
@@ -898,17 +923,20 @@ -(void)refrashMessage:(NIMMessage *)message From:(NSString *)from {
898923
[dic2 setObject:[NSString stringWithFormat:@"%@",object.coverPath] forKey:@"coverPath"];
899924
}
900925
}];
901-
}
926+
}*/
902927
if ([[NSFileManager defaultManager] fileExistsAtPath:object.path]) {
903928
[dic2 setObject:[NSString stringWithFormat:@"%@",object.path] forKey:@"mediaPath"];
904929
}else{
905930

906931
[[NIMObject initNIMObject] downLoadVideo:object Error:^(NSError *error) {
907932
if (!error) {
908933
[dic2 setObject:[NSString stringWithFormat:@"%@",object.path] forKey:@"mediaPath"];
934+
NSLog(@"--------下载完成~!!!dic2:%@",dic2);
935+
NIMModel *model = [NIMModel initShareMD];
936+
model.videoProgress = [NSMutableArray arrayWithObjects:dic2, nil];
909937
}
910938
} progress:^(float progress) {
911-
NSLog(@"下载进度%.f",progress);
939+
NSLog(@"----------下载进度%f dic2:%@",progress,dic2);
912940
}];
913941
}
914942
}else if(message.messageType == NIMMessageTypeLocation){

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ typedef void(^onSuccess)(NSInteger index,id param);
3030
@property(nonatomic,strong)NSDictionary *audioDic;
3131
@property (strong, nonatomic) NSDictionary *deleteMessDict;//撤销时删除的消息ID
3232
@property (strong, nonatomic) NSDictionary *accountNoticeDict;//接收到资金变动的消息
33+
@property(nonatomic,strong)NSMutableArray *videoProgress;
3334
- (void)insertMessages:(NSArray *)messages;
3435
@end

ios/RNNeteaseIm/RNNeteaseIm/NIMModel.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,10 @@ - (void)setAccountNoticeDict:(NSDictionary *)accountNoticeDict{
153153
}
154154
}
155155

156+
- (void)setVideoProgress:(NSMutableArray *)videoProgress{
157+
if (self.myBlock) {
158+
self.myBlock(17, videoProgress);
159+
}
160+
}
161+
156162
@end

ios/RNNeteaseIm/RNNeteaseIm/RNNeteaseIm.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ - (void)removAllRecentSessions{
341341
}
342342
//发送视频消息
343343
RCT_EXPORT_METHOD(sendVideoMessage:(nonnull NSString *)file duration:(nonnull NSString *)duration width:(nonnull NSString *)width height:(nonnull NSString *)height displayName:(nonnull NSString *)displayName){
344-
[[ConversationViewController initWithConversationViewController]sendTextMessage:file duration:duration width:width height:height displayName:displayName];
344+
[[ConversationViewController initWithConversationViewController]sendVideoMessage:file duration:duration width:width height:height displayName:displayName];
345+
345346
}
347+
346348
//发送地理位置消息
347349
RCT_EXPORT_METHOD(sendLocationMessage:(nonnull NSString *)latitude longitude:(nonnull NSString *)longitude address:(nonnull NSString *)address){
348350
[[ConversationViewController initWithConversationViewController]sendLocationMessage:latitude longitude:longitude address:address];
@@ -782,6 +784,10 @@ -(void)setSendState{
782784
//资金变动通知
783785
[_bridge.eventDispatcher sendDeviceEventWithName:@"observeAccountNotice" body:param];
784786
break;
787+
case 17:
788+
//下载视频完成通知
789+
[_bridge.eventDispatcher sendDeviceEventWithName:@"observeDownloadVideoNotice" body:param];
790+
break;
785791
default:
786792
break;
787793
}

0 commit comments

Comments
 (0)