我試圖使用MPMovieplayerController
在UITableview
單元格中播放視頻。我在scrollview委託scrollViewDidScroll
內調用視頻播放功能,當它滾動到一個可見的矩形。在UITableview單元格中播放視頻
我用下面的代碼爲:
- (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
狀態時,它總是處於停止狀態。
僅當從屏幕上移除觸摸後纔會開始播放。有沒有什麼正確的方法來實現這一目標?
感謝您編輯Jeffery :) – 2015-02-10 11:19:59
與AVplayer一起播放視頻。 – 2015-02-13 11:00:15
@VineeshTP:已經實現:) – 2015-02-13 12:23:01