Only Play videos on visible cell


This question already has an answer here:


I developed something similar, was adding view (with video) to a custom cell and call -updateVisibility method on -didScroll delegate of tableView

assuming that self here is a your view with video

    - (void)updateVisibilityInScrollView:(UIScrollView*)scrollView
        if (!self.superview) {
    // Get rect of video relative to scrollView (which is tableView)
        CGRect relativeToScrollViewRect = [self convertRect:self.bounds toView:scrollView];
// get visible scrollView rect
        CGRect visibleScrollViewRect = CGRectMake(scrollView.contentOffset.x, scrollView.contentOffset.y, scrollView.bounds.size.width, scrollView.bounds.size.height);

        if ([self moreThenHalfOfRect:relativeToScrollViewRect visibleInRect:visibleScrollViewRect]) {
            // visible half - resume
        } else {
            // supposed to be paused

- (BOOL)moreThenHalfOfRect:(CGRect)rect visibleInRect:(CGRect)visibleRect
    return (CGRectContainsPoint(visibleRect, CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect))));

Ofcaurce, you can modify to show video for fully visible cells

Sorry I just copied my solution (don't have swift example).

Need Your Help

poll implemenation on linux vs poll implementation on solaris

c linux solaris

During debugging our application in linux enviroment we can observe that some events - POLLHUP|POLLIN occur only on linux. Our application uses unix sockets. When we do:

C# How to drag drop a firefox tab to a winform application

c# html firefox drag-and-drop

In firefox, you can dragdrop tabs to either bookmarks or any text field, but is it possible to drag drop these tab outside of firefox?