How can i implement this player in UITableViewCells?
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.

After reload i insert some records (objects) in tableview and reload. The UI is disturbed and SRVideoPlayer's objects are misplaced.

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.
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.
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 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.