SRVideoPlayer icon indicating copy to clipboard operation
SRVideoPlayer copied to clipboard

How can i implement this player in UITableViewCells?

Open chetan-duke opened this issue 8 years ago • 3 comments

I have implemented player in UITableViewCells. Its not working properly as it has to. When cell is reuse i need its state as its previously has. When i reload the tableview the video layer of one cell is copied to another cells video layer. Below is the screen when tableview is not reloaded yet.

simulator screen shot 15-feb-2017 3 10 03 pm

After reload i insert some records (objects) in tableview and reload. The UI is disturbed and SRVideoPlayer's objects are misplaced. simulator screen shot 15-feb-2017 3 11 04 pm

TableViewCell are XIB's

Code in VideoCell.h @property (nonatomic, strong) SRVideoPlayer *videoPlayer;

Code in ViewController cellForRowAtIndexPath

if (cell.videoPlayer == nil) {
                    cell.videoPlayer = [SRVideoPlayer playerWithVideoURL:[NSURL URLWithString:videoUrl] playerView:cell.viewVideoLayer playerSuperView:cell.viewVideoLayer.superview];
                    cell.videoPlayer.videoName = [[arrData objectAtIndex:indexPath.row] objectForKey:MessageUserFullName];
                    cell.videoPlayer.playerEndAction = SRVideoPlayerEndActionLoop;
                    [cell.videoPlayer play];
                    [cell.vwContents bringSubviewToFront:cell.viewVideoLayer];
}

If I'm going wrong anywhere please update.

chetan-duke avatar Feb 15 '17 10:02 chetan-duke

i guess you should add function

  • (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

    [cell removeFromSuperview]; cell = nil; } in cellForRowAtIndexPath function always create cell again because SRVideoPlayer init must have playerWithVideoURL

  • (instancetype)playerWithVideoURL:(NSURL *)videoURL playerView:(UIView *)playerView playerSuperView:(UIView *)playerSuperView;

or you write new init function for your project.

tommyz avatar Mar 01 '17 03:03 tommyz

Thanks @tommyz , I already done with your suggestion. And another thing my requirement is like Facebook that auto play video, and after cell disappear and re-appear it resume from last paused. I need help on it. I found this lib as useful for me. But if any lib or video player that you know which has same feature like Facebook has, please update here. I need like or comment on video while its playing. so also i need to reload cell for height adjustment.

chetan-duke avatar Mar 28 '17 07:03 chetan-duke

@chetan-duke this lib player not method to setting seek to seconds maybe you need change other lib and add arrdata include object more player currentTime data structure.

tommyz avatar Jun 03 '17 08:06 tommyz