0

我試圖使用MPMovieplayerControllerUITableview單元格中播放視頻。我在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狀態時,它總是處於停止狀態。

僅當從屏幕上移除觸摸後纔會開始播放。有沒有什麼正確的方法來實現這一目標?

+0

感謝您編輯Jeffery :) – 2015-02-10 11:19:59

+0

與AVplayer一起播放視頻。 – 2015-02-13 11:00:15

+0

@VineeshTP:已經實現:) – 2015-02-13 12:23:01

回答

1

用AVPlayer替換MPMoviePlayer解決了這個問題。

+0

你可能會詳細闡述一些關於你如何使用AVPlayer做的事情嗎?我有一個關於AVPlayer在UITableViewCell中播放視頻的問題:http://stackoverflow.com/questions/36168519/playing-video-in-uitableview-cell – joey 2016-03-23 02:37:46