I am trying to play the video in the cells themselves instead of the full screen video. For this purpose I use MPMoviePlayerController.
I determined
MPMoviePlayerController *moviePlayer;
in the implementation section
Then in cellForRowAtIndexPath:
I'm doing it
cell = [tableView dequeueReusableCellWithIdentifier:simpleTableVideoIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableVideoIdentifier];
}
NSDictionary *dictionary = [dataArray objectAtIndex:indexPath.section];
NSDictionary *data = dictionary;
if ([data[@"type_of_post"] isEqualToString:@"video"]) {
NSString *path = data[@"video"];
NSURL *videoURL = [NSURL URLWithString:path];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
[moviePlayer.view setFrame:CGRectMake(10.0, 0.0, 300.0 , 400.0)];
[cell addSubview:moviePlayer.view];
moviePlayer.view.hidden = NO;
[moviePlayer prepareToPlay];
[moviePlayer play];
}else{
}
and obviously assign him a height of heightForRowAtIndexPath:
but the point that it is MPMoviePlayerController *moviePlayer;determined globally does not stick to its cell, but continues to descend as it scrolls down. I do not know what other way to implement this, besides what I have described, which clearly does not seem to be the right way. I would really appreciate it if someone could lead me in the right direction.
thank
source
share