UITableview
を使用してセル内でビデオを再生しようとしていMPMovieplayerController
ます。scrollViewDidScroll
表示されている四角形にスクロールするときに、scrollview delegate 内でビデオ再生関数を呼び出しています。
そのために次のコードを使用しました。
- (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;
}
}
しかし、画面から指を離した後にのみ、ビデオの再生が開始されます。指を離さずに動画を再生したい(つるアプリと同様)。ビューでタッチ中に状態を確認するMPMoviePlayer
と、常に停止状態になります。
画面からタッチを離した後にのみ再生が開始されます。これを達成する正しい方法はありますか?