0

I'm trying to play a video in UITableview cell using MPMovieplayerController. I'm calling the video play function inside scrollview delegate scrollViewDidScroll, when it scrolls to a visible rect.

I used the following codes for that:

- (void)scrollViewDidScroll:(UIScrollView *)aScrollView {

    CGPoint offset = aScrollView.contentOffset;
    CGRect bounds = aScrollView.bounds;
    CGSize size = aScrollView.contentSize;
    UIEdgeInsets inset = aScrollView.contentInset;
    float y = offset.y + bounds.size.height - inset.bottom;
    float h = size.height;
    /*
     NSLog(@"offset: %f", offset.y);
     NSLog(@"content.height: %f", size.height);
     NSLog(@"bounds.height: %f", bounds.size.height);
     NSLog(@"inset.top: %f", inset.top);
     NSLog(@"inset.bottom: %f", inset.bottom);
     NSLog(@"pos: %f of %f", y, h);
     */

    if(offset.y - 100 > bounds.size.height/2 && !playLock)
    {

        [self performSelectorOnMainThread:@selector(startPlayingVideo) withObject:nil waitUntilDone:YES];
        playLock = YES;
    }
}

But the video starts playing only after when I remove fingers from screen. I want to play video without releasing the fingers (Similar to the vine app). When I checked MPMoviePlayer state during my touch in the view, it always falls to stopped state.

It will start playing only after removing the touch from the screen. Is there any right way to achieve this?

Jeffery Thomas
  • 42,202
  • 8
  • 92
  • 117
Vishnu Kumar. S
  • 1,797
  • 1
  • 15
  • 35

1 Answers1

1

Solved this issue by replacing MPMoviePlayer with AVPlayer.

Vishnu Kumar. S
  • 1,797
  • 1
  • 15
  • 35
  • could you maybe elaborate some on how you did it with AVPlayer? I have a question about AVPlayer playing video in UITableViewCell here: http://stackoverflow.com/questions/36168519/playing-video-in-uitableview-cell – jjjjjjjj Mar 23 '16 at 02:37