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?