Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议微信聊天图片视频浏览支持一下本地路径的图片与视频资源(发送方一般会用到) #191

Open
jozdee opened this issue Apr 12, 2024 · 0 comments

Comments

@jozdee
Copy link

jozdee commented Apr 12, 2024

  • (void)showBrowserWithIndex:(NSInteger)index {
    NSMutableArray *photos = [NSMutableArray new];
    [self.dataSource enumerateObjectsUsingBlock:^(GKTimeLineModel *model, NSUInteger idx, BOOL * _Nonnull stop) {
    GKChatViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:idx inSection:0]];
    GKTimeLineImage *img = model.images.firstObject;

      GKPhoto *photo = [GKPhoto new];
      photo.url = [NSURL URLWithString:img.url];
      photo.sourceImageView = cell.imgView;
      if (img.isVideo) {
          photo.videoUrl = [NSURL URLWithString:img.video_url];
          photo.autoPlay = NO;
      }
      
      // 首次点击的是视频,自动播放
      if (img.isVideo && index == idx) {
          photo.isVideoClicked = YES;
      }
      
      [photos addObject:photo];
    

    }];

    GKPhotoBrowser *browser = [GKPhotoBrowser photoBrowserWithPhotos:photos currentIndex:index];
    browser.showStyle = GKPhotoBrowserShowStyleZoom;
    browser.hideStyle = GKPhotoBrowserHideStyleZoomScale;
    browser.hidesPageControl = YES;
    browser.hidesSavedBtn = YES;
    browser.hidesCountLabel = YES;
    browser.delegate = self;
    browser.isSingleTapDisabled = YES;
    browser.isVideoPausedWhenDragged = NO;
    [browser setupVideoProgressProtocol:[GKVideoProgressView new]];
    browser.isVideoReplay = NO;
    [browser showFromVC:self];
    }

#pragma mark - GKPhotoBrowserDelegate

  • (void)photoBrowser:(GKPhotoBrowser *)browser singleTapWithIndex:(NSInteger)index {
    GKPhoto *photo = browser.curPhoto;
    if (photo.isVideo) {
    browser.progressView.hidden = !browser.progressView.isHidden;
    }else {
    [browser dismiss];
    }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant