heavyrain2012 4 tahun lalu
induk
melakukan
58a3c5e5da

+ 1 - 1
wfclient/WFChatClient/Messages/WFCCFileMessageContent.m

@@ -26,7 +26,7 @@
     WFCCMediaMessagePayload *payload = [[WFCCMediaMessagePayload alloc] init];
     payload.extra = self.extra;
     payload.contentType = [self.class getContentType];
-    payload.searchableContent = [NSString stringWithFormat:@"[文件] %@", self.name];
+    payload.searchableContent = self.name;
     payload.content = [NSString stringWithFormat:@"%ld", (long)self.size];
     payload.mediaType = Media_Type_FILE;
     

+ 5 - 2
wfclient/WFChatClient/Messages/WFCCSoundMessageContent.m

@@ -73,10 +73,13 @@
         self.remoteUrl = mediaPayload.remoteMediaUrl;
         self.localPath = mediaPayload.localMediaPath;
         
+        NSError *__error = nil;
         NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[payload.content dataUsingEncoding:NSUTF8StringEncoding]
                                                                    options:kNilOptions
-                                                                     error:nil];
-        self.duration = [dictionary[@"duration"] longValue];
+                                                                     error:&__error];
+        if (!__error) {
+            self.duration = [dictionary[@"duration"] longValue];
+        }
     }
 }
 

+ 5 - 0
wfclient/WFChatClient/Messages/WFCCVideoMessageContent.h

@@ -27,4 +27,9 @@
  */
 @property (nonatomic, strong)UIImage *thumbnail;
 
+/**
+ 时长
+*/
+@property (nonatomic, assign)long duration;
+
 @end

+ 19 - 1
wfclient/WFChatClient/Messages/WFCCVideoMessageContent.m

@@ -11,7 +11,7 @@
 #import "WFCCIMService.h"
 #import "WFCCUtilities.h"
 #import "Common.h"
-
+#import <AVFoundation/AVFoundation.h>
 
 @implementation WFCCVideoMessageContent
 + (instancetype)contentPath:(NSString *)localPath thumbnail:(UIImage *)image {
@@ -19,6 +19,11 @@
     content.localPath = localPath;
     content.thumbnail = [WFCCUtilities imageWithRightOrientation:image];
     
+    NSURL *videoUrl = [NSURL URLWithString:localPath];
+    AVURLAsset *avUrl = [AVURLAsset assetWithURL:videoUrl];
+    CMTime time = [avUrl duration];
+    content.duration = ceil(time.value/time.timescale);
+
     return content;
 }
 - (WFCCMessagePayload *)encode {
@@ -30,6 +35,11 @@
     payload.mediaType = Media_Type_VIDEO;
     payload.remoteMediaUrl = self.remoteUrl;
     payload.localMediaPath = self.localPath;
+    
+    NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
+    [dict setObject:@(_duration) forKey:@"duration"];
+    payload.content = [[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:dict options:kNilOptions error:nil] encoding:NSUTF8StringEncoding];
+    
     return payload;
 }
 
@@ -40,6 +50,14 @@
         self.thumbnail = [UIImage imageWithData:payload.binaryContent];
         self.remoteUrl = mediaPayload.remoteMediaUrl;
         self.localPath = mediaPayload.localMediaPath;
+        
+        NSError *__error = nil;
+        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[payload.content dataUsingEncoding:NSUTF8StringEncoding]
+                                                                   options:kNilOptions
+                                                                     error:&__error];
+        if (!__error) {
+            self.duration = [dictionary[@"duration"] longValue];
+        }
     }
 }
 

+ 1 - 1
wfclient/WFChatClient/Utility/WFCCUtilities.m

@@ -258,7 +258,7 @@ static NSLock *wfcImageLock;
 
     NSNumber *createTime = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"wfc_group_generate_portrait_time_%@", groupId]];
     long now = [[[NSDate alloc] init] timeIntervalSince1970];
-    if (now - [createTime longLongValue] < 10 * 1000) {//防止连续刷新时,多次生成
+    if ((now - [createTime longLongValue]) < 15) {//防止连续刷新时,多次生成
         return;
     }
     

+ 16 - 0
wfuikit/WFChatUIKit.xcodeproj/project.pbxproj

@@ -26,6 +26,10 @@
 		149B3112241E65D500B935D3 /* UIFont+YH.m in Sources */ = {isa = PBXBuildFile; fileRef = 149B310E241E65D500B935D3 /* UIFont+YH.m */; };
 		2B07FBE1247562D90035C4DF /* WFCUReceiptViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B07FBDF247562D90035C4DF /* WFCUReceiptViewController.h */; };
 		2B07FBE2247562D90035C4DF /* WFCUReceiptViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B07FBE0247562D90035C4DF /* WFCUReceiptViewController.m */; };
+		2B46D4D824ACC64300721792 /* WFCUMediaMessageGridViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B46D4D624ACC64300721792 /* WFCUMediaMessageGridViewController.h */; };
+		2B46D4D924ACC64300721792 /* WFCUMediaMessageGridViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B46D4D724ACC64300721792 /* WFCUMediaMessageGridViewController.m */; };
+		2B46D4DC24ACC9B900721792 /* MediaMessageGridViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B46D4DA24ACC9B900721792 /* MediaMessageGridViewCell.h */; };
+		2B46D4DD24ACC9B900721792 /* MediaMessageGridViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B46D4DB24ACC9B900721792 /* MediaMessageGridViewCell.m */; };
 		2B63367E24716864008D6B38 /* ZCCCircleProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 2B63367C24716864008D6B38 /* ZCCCircleProgressView.m */; };
 		2B63367F24716864008D6B38 /* ZCCCircleProgressView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2B63367D24716864008D6B38 /* ZCCCircleProgressView.h */; };
 		2BD671A42336E821007A9FEC /* WFCUConfigManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BD671A22336E821007A9FEC /* WFCUConfigManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -401,6 +405,10 @@
 		149B310E241E65D500B935D3 /* UIFont+YH.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFont+YH.m"; sourceTree = "<group>"; };
 		2B07FBDF247562D90035C4DF /* WFCUReceiptViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WFCUReceiptViewController.h; sourceTree = "<group>"; };
 		2B07FBE0247562D90035C4DF /* WFCUReceiptViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WFCUReceiptViewController.m; sourceTree = "<group>"; };
+		2B46D4D624ACC64300721792 /* WFCUMediaMessageGridViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WFCUMediaMessageGridViewController.h; sourceTree = "<group>"; };
+		2B46D4D724ACC64300721792 /* WFCUMediaMessageGridViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WFCUMediaMessageGridViewController.m; sourceTree = "<group>"; };
+		2B46D4DA24ACC9B900721792 /* MediaMessageGridViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MediaMessageGridViewCell.h; sourceTree = "<group>"; };
+		2B46D4DB24ACC9B900721792 /* MediaMessageGridViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MediaMessageGridViewCell.m; sourceTree = "<group>"; };
 		2B63367C24716864008D6B38 /* ZCCCircleProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZCCCircleProgressView.m; sourceTree = "<group>"; };
 		2B63367D24716864008D6B38 /* ZCCCircleProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZCCCircleProgressView.h; sourceTree = "<group>"; };
 		2BCEC52D232E10DF00D55E0D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/wfc.strings; sourceTree = "<group>"; };
@@ -943,6 +951,8 @@
 				2F550EBA217F5CC000F56C26 /* WFCUVoiceCell.m */,
 				2FD550EA2442AA0B00B3EE09 /* WFCURecallCell.h */,
 				2FD550EB2442AA0B00B3EE09 /* WFCURecallCell.m */,
+				2B46D4DA24ACC9B900721792 /* MediaMessageGridViewCell.h */,
+				2B46D4DB24ACC9B900721792 /* MediaMessageGridViewCell.m */,
 			);
 			path = Cell;
 			sourceTree = "<group>";
@@ -961,6 +971,8 @@
 			children = (
 				2F550ED0217F5CC000F56C26 /* WFCUMessageListViewController.m */,
 				2F550ED1217F5CC000F56C26 /* WFCUMessageListViewController.h */,
+				2B46D4D624ACC64300721792 /* WFCUMediaMessageGridViewController.h */,
+				2B46D4D724ACC64300721792 /* WFCUMediaMessageGridViewController.m */,
 			);
 			path = ViewController;
 			sourceTree = "<group>";
@@ -1776,6 +1788,7 @@
 				2F551096217F5CC200F56C26 /* WFCUImageCell.h in Headers */,
 				2F5510AF217F5CC200F56C26 /* WFCUInviteGroupMemberViewController.h in Headers */,
 				2F5511EB217F5CC300F56C26 /* WFCUShareMessageView.h in Headers */,
+				2B46D4DC24ACC9B900721792 /* MediaMessageGridViewCell.h in Headers */,
 				2F5511A2217F5CC200F56C26 /* NSImage+WebCache.h in Headers */,
 				2F5510B2217F5CC200F56C26 /* WFCUImagePreviewViewController.h in Headers */,
 				2F5510EA217F5CC200F56C26 /* WFCUEmotionTextAttachment.h in Headers */,
@@ -1855,6 +1868,7 @@
 				2F55116F217F5CC200F56C26 /* AFHTTPSessionManager.h in Headers */,
 				2F5510A8217F5CC200F56C26 /* WFCUVideoCell.h in Headers */,
 				90414AFC21AF5A93008EF915 /* WFCUConversationSearchTableViewCell.h in Headers */,
+				2B46D4D824ACC64300721792 /* WFCUMediaMessageGridViewController.h in Headers */,
 				2F55115A217F5CC200F56C26 /* SDPhotoBrowserConfig.h in Headers */,
 				2F55110C217F5CC200F56C26 /* FullScreenView.h in Headers */,
 			);
@@ -1992,6 +2006,7 @@
 				2F5511E8217F5CC300F56C26 /* WFCUShareMessageView.m in Sources */,
 				2F55121B217F5CC300F56C26 /* WFCUMessageNotificationViewController.m in Sources */,
 				2F5511C4217F5CC300F56C26 /* NSImage+WebCache.m in Sources */,
+				2B46D4D924ACC64300721792 /* WFCUMediaMessageGridViewController.m in Sources */,
 				2F55120A217F5CC300F56C26 /* WFCUConversationTableViewController.m in Sources */,
 				2F551167217F5CC200F56C26 /* AFURLResponseSerialization.m in Sources */,
 				2F551112217F5CC200F56C26 /* VideoPlayerSampleViewController.m in Sources */,
@@ -2027,6 +2042,7 @@
 				2F551091217F5CC200F56C26 /* WFCUMediaMessageCell.m in Sources */,
 				2F5511FA217F5CC300F56C26 /* UIView+Toast.m in Sources */,
 				2BEF78A723F6A84D000DE285 /* WFCUVideoViewController.m in Sources */,
+				2B46D4DD24ACC9B900721792 /* MediaMessageGridViewCell.m in Sources */,
 				2F5510AB217F5CC200F56C26 /* WFCUMessageListViewController.m in Sources */,
 				2F551126217F5CC200F56C26 /* VideoPlayerView.m in Sources */,
 				2F5511F6217F5CC300F56C26 /* TabbarButton.m in Sources */,

+ 8 - 5
wfuikit/WFChatUIKit/Group/Model/WFCUGroupAnnouncement.m

@@ -20,11 +20,14 @@
 
 - (void)setData:(NSData *)data {
     if (data) {
-        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
-        self.groupId = [dict objectForKey:@"gid"];
-        self.author = [dict objectForKey:@"a"];
-        self.text = [dict objectForKey:@"t"];
-        self.timestamp = [[dict objectForKey:@"ts"] longValue];
+        NSError *__error = nil;
+        NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&__error];
+        if (!__error) {
+            self.groupId = [dict objectForKey:@"gid"];
+            self.author = [dict objectForKey:@"a"];
+            self.text = [dict objectForKey:@"t"];
+            self.timestamp = [[dict objectForKey:@"ts"] longValue];
+        }
     }
 }
 

+ 17 - 0
wfuikit/WFChatUIKit/MessageList/Cell/MediaMessageGridViewCell.h

@@ -0,0 +1,17 @@
+//
+//  MediaMessageGridViewCell.h
+//  WFChatUIKit
+//
+//  Created by dali on 2020/7/1.
+//  Copyright © 2020 Tom Lee. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+@class WFCCMessage;
+@interface MediaMessageGridViewCell : UICollectionViewCell
+@property(nonatomic, strong)WFCCMessage *mediaMessage;
+@end
+
+NS_ASSUME_NONNULL_END

+ 113 - 0
wfuikit/WFChatUIKit/MessageList/Cell/MediaMessageGridViewCell.m

@@ -0,0 +1,113 @@
+//
+//  MediaMessageGridViewCell.m
+//  WFChatUIKit
+//
+//  Created by dali on 2020/7/1.
+//  Copyright © 2020 Tom Lee. All rights reserved.
+//
+
+#import "MediaMessageGridViewCell.h"
+#import <WFChatClient/WFCChatClient.h>
+
+@interface MediaMessageGridViewCell ()
+@property(nonatomic, strong)UIImageView *imageView;
+@property(nonatomic, strong)UIImageView *videoFlag;
+@property(nonatomic, strong)UILabel *videoDuration;
+
+@property(nonatomic, strong)UILabel *fileName;
+@property(nonatomic, strong)UILabel *fileSize;
+@end
+
+@implementation MediaMessageGridViewCell
+-(void)setMediaMessage:(WFCCMessage *)mediaMessage {
+    _mediaMessage = mediaMessage;
+    if ([mediaMessage.content isKindOfClass:[WFCCImageMessageContent class]]) {
+        WFCCImageMessageContent *imgCnt = (WFCCImageMessageContent *)mediaMessage.content;
+        self.imageView.image = imgCnt.thumbnail;
+        
+        self.imageView.hidden = NO;
+        self.videoFlag.hidden = YES;
+        self.videoDuration.hidden = YES;
+        self.fileSize.hidden = YES;
+        self.fileName.hidden = YES;
+    } else if([mediaMessage.content isKindOfClass:[WFCCVideoMessageContent class]]) {
+        WFCCVideoMessageContent *videoCnt = (WFCCVideoMessageContent *)mediaMessage.content;
+        self.imageView.image = videoCnt.thumbnail;
+        if (videoCnt.duration == 0) {
+            self.videoDuration.text = nil;
+        } else if(videoCnt.duration > 60) {
+            self.videoDuration.text = [NSString stringWithFormat:@"%ld:%2ld", videoCnt.duration/60, videoCnt.duration%60];
+        } else {
+            self.videoDuration.text = [NSString stringWithFormat:@"0:%2ld", videoCnt.duration];
+        }
+        
+        
+        self.imageView.hidden = NO;
+        self.videoFlag.hidden = NO;
+        self.videoDuration.hidden = NO;
+        self.fileSize.hidden = YES;
+        self.fileName.hidden = YES;
+    } else if([mediaMessage.content isKindOfClass:[WFCCFileMessageContent class]]) {
+        WFCCFileMessageContent *fileCnt = (WFCCFileMessageContent *)mediaMessage.content;
+        self.fileName.text = fileCnt.name;
+        if (fileCnt.size > 1024 * 1024) {
+            self.fileSize.text = [NSString stringWithFormat:@"%ldM", fileCnt.size/1024/1024];
+        } else if(fileCnt.size > 1024) {
+            self.fileSize.text = [NSString stringWithFormat:@"%ldK", fileCnt.size/1024];
+        } else {
+            self.fileSize.text = [NSString stringWithFormat:@"%ldB", fileCnt.size];
+        }
+        
+        self.backgroundColor = [UIColor grayColor];
+        
+        self.imageView.hidden = YES;
+        self.videoFlag.hidden = YES;
+        self.videoDuration.hidden = YES;
+        self.fileSize.hidden = NO;
+        self.fileName.hidden = NO;
+    }
+}
+- (UIImageView *)imageView {
+    if (!_imageView) {
+        _imageView = [[UIImageView alloc] initWithFrame:self.bounds];
+        [self addSubview:_imageView];
+    }
+    return _imageView;
+}
+- (UIImageView *)videoFlag {
+    if (!_videoFlag) {
+        _videoFlag = [[UIImageView alloc] initWithFrame:CGRectMake(8, self.bounds.size.height-24, 15, 12)];
+        _videoFlag.image = [UIImage imageNamed:@"video"];
+        [self addSubview:_videoFlag];
+    }
+    return _videoFlag;
+}
+-(UILabel *)videoDuration {
+    if (!_videoDuration) {
+        _videoDuration = [[UILabel alloc] initWithFrame:CGRectMake(28, self.bounds.size.height-24-2, 40, 16)];
+        _videoDuration.font = [UIFont systemFontOfSize:12];
+        _videoDuration.lineBreakMode = NSLineBreakByTruncatingHead;
+        [self addSubview:_videoDuration];
+    }
+    return _videoDuration;
+}
+-(UILabel *)fileName {
+    if (!_fileName) {
+        _fileName = [[UILabel alloc] initWithFrame:CGRectMake(8, 8, self.bounds.size.width-16, 40)];
+        _fileName.font = [UIFont systemFontOfSize:14];
+        _fileName.lineBreakMode = NSLineBreakByTruncatingMiddle;
+        _fileName.numberOfLines = 2;
+        [self addSubview:_fileName];
+    }
+    return _fileName;
+}
+-(UILabel *)fileSize {
+    if (!_fileSize) {
+        _fileSize = [[UILabel alloc] initWithFrame:CGRectMake(8, self.bounds.size.height-24, self.bounds.size.width-16, 16)];
+        _fileSize.font = [UIFont systemFontOfSize:14];
+        _fileSize.lineBreakMode = NSLineBreakByTruncatingHead;
+        [self addSubview:_fileSize];
+    }
+    return _fileSize;
+}
+@end

+ 18 - 0
wfuikit/WFChatUIKit/MessageList/ViewController/WFCUMediaMessageGridViewController.h

@@ -0,0 +1,18 @@
+//
+//  WFCUMediaMessageGridViewController.h
+//  WFChatUIKit
+//
+//  Created by dali on 2020/7/1.
+//  Copyright © 2020 Tom Lee. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+@class WFCCConversation;
+
+@interface WFCUMediaMessageGridViewController : UIViewController
+@property(nonatomic, strong)WFCCConversation *conversation;
+@end
+
+NS_ASSUME_NONNULL_END

+ 122 - 0
wfuikit/WFChatUIKit/MessageList/ViewController/WFCUMediaMessageGridViewController.m

@@ -0,0 +1,122 @@
+//
+//  WFCUMediaMessageGridViewController.m
+//  WFChatUIKit
+//
+//  Created by dali on 2020/7/1.
+//  Copyright © 2020 Tom Lee. All rights reserved.
+//
+
+#import "WFCUMediaMessageGridViewController.h"
+#import <WFChatClient/WFCChatClient.h>
+#import "MediaMessageGridViewCell.h"
+#import "SDPhotoBrowser.h"
+#import "WFCUBrowserViewController.h"
+#import "WFCUMediaMessageDownloader.h"
+#import "VideoPlayerKit.h"
+
+@interface WFCUMediaMessageGridViewController () <UICollectionViewDataSource, UICollectionViewDelegate, SDPhotoBrowserDelegate>
+@property(nonatomic, strong)UICollectionView *collectionView;
+@property(nonatomic, strong)NSMutableArray<WFCCMessage *> *mediaMessages;
+@property(nonatomic, strong)WFCCMessage *selectedMsg;
+
+@property(nonatomic, strong)VideoPlayerKit *videoPlayerViewController;
+@end
+
+@implementation WFCUMediaMessageGridViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    
+    UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc]init];
+    CGFloat edgeInset = 5;
+    int countInLine = 4;
+    flowLayout.sectionInset = UIEdgeInsetsMake(edgeInset, edgeInset, edgeInset, edgeInset);
+    CGFloat width = [UIScreen mainScreen].bounds.size.width;
+    width = width/countInLine - edgeInset - edgeInset;
+    flowLayout.itemSize = CGSizeMake(width, width);
+    
+    self.collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
+    self.collectionView.dataSource = self;
+    self.collectionView.delegate = self;
+    [self.collectionView registerClass:[MediaMessageGridViewCell class] forCellWithReuseIdentifier:@"cell"];
+    
+    [self.view addSubview:self.collectionView];
+    
+    [self loadMediaMessages];
+    [self.collectionView reloadData];
+}
+
+- (void)loadMediaMessages {
+    self.mediaMessages = [[[WFCCIMService sharedWFCIMService] getMessages:self.conversation contentTypes:@[@(MESSAGE_CONTENT_TYPE_IMAGE), @(MESSAGE_CONTENT_TYPE_FILE), @(MESSAGE_CONTENT_TYPE_VIDEO)] from:0 count:20 withUser:nil] mutableCopy];
+}
+
+#pragma mark - UICollectionViewDataSource
+- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
+    return self.mediaMessages.count;
+}
+
+- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
+    MediaMessageGridViewCell *cell = (MediaMessageGridViewCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
+    WFCCMessage *msg = self.mediaMessages[indexPath.row];
+    cell.mediaMessage = msg;
+    return cell;
+}
+
+- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
+    return 1;
+}
+
+- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
+    self.selectedMsg = self.mediaMessages[indexPath.row];
+    if ([self.selectedMsg.content isKindOfClass:[WFCCImageMessageContent class]]) {
+        SDPhotoBrowser *browser = [[SDPhotoBrowser alloc] init];
+        browser.sourceImagesContainerView = self.view;
+        browser.showAll = NO;
+        browser.imageCount = 1;
+        
+        browser.currentImageIndex = 0;
+        browser.delegate = self;
+        [browser show]; // 展示图片浏览器
+    } else if([self.selectedMsg.content isKindOfClass:[WFCCFileMessageContent class]]) {
+        WFCCFileMessageContent *fileContent = (WFCCFileMessageContent *)self.selectedMsg.content;
+        WFCUBrowserViewController *bvc = [[WFCUBrowserViewController alloc] init];
+        bvc.url = fileContent.remoteUrl;
+        [self.navigationController pushViewController:bvc animated:YES];
+    } else if([self.selectedMsg.content isKindOfClass:[WFCCVideoMessageContent class]]) {
+        WFCCVideoMessageContent *videoMsg = (WFCCVideoMessageContent *)self.selectedMsg.content;
+        if (self.selectedMsg.direction == MessageDirection_Receive && self.selectedMsg.status != Message_Status_Played) {
+            [[WFCCIMService sharedWFCIMService] setMediaMessagePlayed:self.selectedMsg.messageId];
+            
+        }
+        
+        [self startPlayVideo:videoMsg];
+    }
+}
+- (void)startPlayVideo:(WFCCVideoMessageContent *)videoMsg {
+    NSURL *url = [NSURL URLWithString:videoMsg.remoteUrl];
+    if (!self.videoPlayerViewController) {
+        self.videoPlayerViewController = [VideoPlayerKit videoPlayerWithContainingView:self.view optionalTopView:nil hideTopViewWithControls:YES];
+        self.videoPlayerViewController.allowPortraitFullscreen = YES;
+    } else {
+        [self.videoPlayerViewController.view removeFromSuperview];
+    }
+    
+    [self.view addSubview:self.videoPlayerViewController.view];
+    
+    [self.videoPlayerViewController playVideoWithTitle:@" " URL:url videoID:nil shareURL:nil isStreaming:NO playInFullScreen:YES];
+}
+
+#pragma mark - SDPhotoBrowserDelegate
+- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index {
+    WFCCImageMessageContent *imgCnt = (WFCCImageMessageContent *)self.selectedMsg.content;
+    return imgCnt.thumbnail;
+}
+
+- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index {
+    WFCCImageMessageContent *imgContent = (WFCCImageMessageContent *)self.selectedMsg.content;
+    return [NSURL URLWithString:[imgContent.remoteUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+}
+- (void)photoBrowserDidDismiss:(SDPhotoBrowser *)browser {
+    self.selectedMsg = nil;
+}
+@end

+ 10 - 17
wfuikit/WFChatUIKit/MessageList/ViewController/WFCUMessageListViewController.m

@@ -59,6 +59,8 @@
 #import "WFCUConversationTableViewController.h"
 #import "WFCUConversationSearchTableViewController.h"
 
+#import "WFCUMediaMessageGridViewController.h"
+
 @interface WFCUMessageListViewController () <UITextFieldDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, UINavigationControllerDelegate, WFCUMessageCellDelegate, AVAudioPlayerDelegate, WFCUChatInputBarDelegate, SDPhotoBrowserDelegate, UIGestureRecognizerDelegate>
 @property (nonatomic, strong)NSMutableArray<WFCUMessageModel *> *modelList;
 @property (nonatomic, strong)NSMutableDictionary<NSNumber *, Class> *cellContentDict;
@@ -1266,11 +1268,10 @@
         [[NSNotificationCenter defaultCenter] postNotificationName:kVoiceMessageStartPlaying object:@(self.playingMessageId)];
     } else if([model.message.content isKindOfClass:[WFCCVideoMessageContent class]]) {
         WFCCVideoMessageContent *videoMsg = (WFCCVideoMessageContent *)model.message.content;
-        NSURL *url = [NSURL fileURLWithPath:[videoMsg.localPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
+        NSURL *url = [NSURL URLWithString:videoMsg.remoteUrl];
         
         if (!self.videoPlayerViewController) {
             self.videoPlayerViewController = [VideoPlayerKit videoPlayerWithContainingView:self.view optionalTopView:nil hideTopViewWithControls:YES];
-            //            self.videoPlayerViewController.delegate = self;
             self.videoPlayerViewController.allowPortraitFullscreen = YES;
         } else {
             [self.videoPlayerViewController.view removeFromSuperview];
@@ -1356,7 +1357,7 @@
         }
         SDPhotoBrowser *browser = [[SDPhotoBrowser alloc] init];
         browser.sourceImagesContainerView = self.backgroundView;
-        
+        browser.showAll = YES;
         browser.imageCount = self.imageMsgs.count;
         int i;
         for (i = 0; i < self.imageMsgs.count; i++) {
@@ -1401,19 +1402,7 @@
             [self.collectionView reloadItemsAtIndexPaths:@[[self.collectionView indexPathForCell:cell]]];
         }
         
-        if (videoMsg.localPath.length == 0) {
-            model.mediaDownloading = YES;
-            __weak typeof(self) weakSelf = self;
-            
-            [[WFCUMediaMessageDownloader sharedDownloader] tryDownload:model.message success:^(long long messageUid, NSString *localPath) {
-                model.mediaDownloading = NO;
-                [weakSelf startPlay:model];
-            } error:^(long long messageUid, int error_code) {
-                model.mediaDownloading = NO;
-            }];
-        } else {
-            [self startPlay:model];
-        }
+        [self startPlay:model];
     }
 }
 
@@ -1765,7 +1754,11 @@
 - (void)photoBrowserDidDismiss:(SDPhotoBrowser *)browser {
     self.imageMsgs = nil;
 }
-
+- (void)photoBrowserShowAllView {
+    WFCUMediaMessageGridViewController *vc = [[WFCUMediaMessageGridViewController alloc] init];
+    vc.conversation = self.conversation;
+    [self.navigationController pushViewController:vc animated:YES];
+}
 #pragma mark - UIGestureRecognizerDelegate
 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
     return self.navigationController.childViewControllers.count > 1;

+ 3 - 1
wfuikit/WFChatUIKit/Vendor/SDPhotoBrowser/SDPhotoBrowser.h

@@ -10,7 +10,6 @@
 
 
 @class SDButton, SDPhotoBrowser;
-
 @protocol SDPhotoBrowserDelegate <NSObject>
 
 @required
@@ -21,6 +20,7 @@
 
 - (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index;
 - (void)photoBrowserDidDismiss:(SDPhotoBrowser *)browser;
+- (void)photoBrowserShowAllView;
 @end
 
 
@@ -32,6 +32,8 @@
 
 @property (nonatomic, weak) id<SDPhotoBrowserDelegate> delegate;
 
+@property (nonatomic, assign)BOOL showAll;
+
 - (void)show;
 
 @end

+ 34 - 2
wfuikit/WFChatUIKit/Vendor/SDPhotoBrowser/SDPhotoBrowser.m

@@ -29,6 +29,7 @@
     BOOL _hasShowedFistView;
     UILabel *_indexLabel;
     UIButton *_saveButton;
+    UIButton *_allButton;
     UIActivityIndicatorView *_indicatorView;
     BOOL _willDisappear;
 }
@@ -84,6 +85,22 @@
     [saveButton addTarget:self action:@selector(saveImage) forControlEvents:UIControlEventTouchUpInside];
     _saveButton = saveButton;
     [self addSubview:saveButton];
+    
+    // Show all button
+    if (self.showAll) {
+        UIButton *allButton = [[UIButton alloc] init];
+        [allButton setTitle:@"全部" forState:UIControlStateNormal];
+        [allButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
+        allButton.backgroundColor = [UIColor colorWithRed:0.1f green:0.1f blue:0.1f alpha:0.90f];
+        allButton.layer.cornerRadius = 5;
+        allButton.clipsToBounds = YES;
+        [allButton addTarget:self action:@selector(allImage) forControlEvents:UIControlEventTouchUpInside];
+        _allButton = allButton;
+        [self addSubview:allButton];
+    } else {
+        _allButton = nil;
+    }
+    
 }
 
 - (void)saveImage
@@ -101,6 +118,17 @@
     [indicator startAnimating];
 }
 
+- (void)allImage {
+    if ([self.delegate respondsToSelector:@selector(photoBrowserShowAllView)]) {
+        [self.delegate photoBrowserShowAllView];
+    }
+    [self removeFromSuperview];
+    if ([self.delegate respondsToSelector:@selector(photoBrowserDidDismiss:)]) {
+        [self.delegate photoBrowserDidDismiss:self];
+    }
+    
+}
+
 - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo;
 {
     [_indicatorView removeFromSuperview];
@@ -202,6 +230,7 @@
     [self addSubview:tempView];
 
     _saveButton.hidden = YES;
+    _allButton.hidden = YES;
     
     [UIView animateWithDuration:SDPhotoBrowserHideImageAnimationDuration animations:^{
         CGRect frame = self.frame;
@@ -212,7 +241,9 @@
         _indexLabel.alpha = 0.1;
     } completion:^(BOOL finished) {
         [self removeFromSuperview];
-        [self.delegate photoBrowserDidDismiss:self];
+        if ([self.delegate respondsToSelector:@selector(photoBrowserDidDismiss:)]) {
+            [self.delegate photoBrowserDidDismiss:self];
+        }
     }];
 }
 
@@ -260,8 +291,9 @@
        // [self showFirstImage];
     }
     
-    _indexLabel.center = CGPointMake(self.bounds.size.width * 0.5, 35);
+    _indexLabel.center = CGPointMake(self.bounds.size.width * 0.5, kStatusBarAndNavigationBarHeight - 64 + 35);
     _saveButton.frame = CGRectMake(30, self.bounds.size.height - 70, 50, 25);
+    _allButton.frame = CGRectMake(100, self.bounds.size.height - 70, 50, 25);
 }
 
 - (void)show

+ 2 - 1
wfuikit/WFChatUIKit/Vendor/VideoPlayerKit/VideoPlayerKit.m

@@ -78,6 +78,7 @@ static const NSTimeInterval controlsAnimationDuration = 0.4;
         self.hideTopViewWithControls = hideTopViewWithControls;
         self.topView = topView;
         self.previousStatusBarStyle = [[UIApplication sharedApplication] statusBarStyle];
+        self.view.backgroundColor = [UIColor blackColor];
     }
     
     return self;
@@ -327,7 +328,7 @@ static const NSTimeInterval controlsAnimationDuration = 0.4;
                              }
                              completion:nil];
         }
-        
+        self.fullscreenViewController.modalPresentationStyle = UIModalPresentationFullScreen;
         [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:self.fullscreenViewController animated:YES completion:^{
             if (self.isAlwaysFullscreen) {
                 self.videoPlayerView.frame = CGRectMake(self.videoPlayerView.superview.bounds.size.width / 2, self.videoPlayerView.superview.bounds.size.height / 2, 0, 0);