guowilling / SRVideoPlayer

Custom interface video player which has various interactive gestures.
MIT License
106 stars 31 forks source link

How can i implement this player in UITableViewCells? #2

Open chetan-duke opened 7 years ago

chetan-duke commented 7 years ago

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.

tommyz commented 7 years ago

i guess you should add function

or you write new init function for your project.

chetan-duke commented 7 years ago

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.

tommyz commented 7 years ago

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