SJBaseVideoPlayer icon indicating copy to clipboard operation
SJBaseVideoPlayer copied to clipboard

Problem in Playing video in UITableView when full screen (landscape video only)

Open aanaipandi22 opened this issue 5 years ago • 3 comments

Dear sir, I am using the latest version 3.0.0. Problem in playing video in UITableView when the full screen button clicked only if the video orientation is landscape. If the video orientation is portrait, not a problem. Only for landscape orientation video only.

Initially I have 15 elements in the tableview array.

I also enabled the autoplay function.

Indexpath=0 , also not a problem. Playing landscape video in portrait mode at indexpath=1, then I click the full screen button then the device automatically rotate to landscape mode. Now Player not playing the first index video, immediately it call the delegate method -(void)sj_playerNeedPlayNewAssetAtIndexPath:(NSIndexPath). Now the new indexpath is 11, player playing the 11 index video. But I want to play first index video only.

After clicking the full screen button, the tableview visible index path array has the value of index path 11,12. But currently I am in index path 1 only.

I tested in XCode 11.0, Simulator iPhone 8 (iOS 13)

What is the problem?

aanaipandi22 avatar Oct 01 '19 17:10 aanaipandi22

Hi @aanaipandi22. has the table view controller rotated?

Please refer to this issue for configuration rotation. https://github.com/changsanjiang/SJVideoPlayer/issues/148

changsanjiang avatar Oct 05 '19 12:10 changsanjiang

Hi, After I added the UIViewController+RotationControl.h & UIViewController+RotationControl.m files in my project, video playing properly. Now, no problem for landscape video. But previous my app support all orientation. After added this file, my app support portrait orientation only.

aanaipandi22 avatar Oct 05 '19 16:10 aanaipandi22

Hi @aanaipandi22 , try these codes below:

@implementation AppDelegate
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationMaskAll;
}
@end


@implementation YourTableViewController
- (BOOL)shouldAutorotate {
    return NO;
}
@end


@implementation UITabBarController (RotationControl)
- (UIViewController *)sj_topViewController {
    if ( self.selectedIndex == NSNotFound )
        return self.viewControllers.firstObject;
    return self.selectedViewController;
}

- (BOOL)shouldAutorotate {
    return [[self sj_topViewController] shouldAutorotate];
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return [[self sj_topViewController] supportedInterfaceOrientations];
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return [[self sj_topViewController] preferredInterfaceOrientationForPresentation];
}
@end

@implementation UINavigationController (RotationControl)
- (BOOL)shouldAutorotate {
    return self.topViewController.shouldAutorotate;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return self.topViewController.supportedInterfaceOrientations;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
    return self.topViewController.preferredInterfaceOrientationForPresentation;
}

- (nullable UIViewController *)childViewControllerForStatusBarStyle {
    return self.topViewController;
}

- (nullable UIViewController *)childViewControllerForStatusBarHidden {
    return self.topViewController;
}
@end

changsanjiang avatar Oct 06 '19 05:10 changsanjiang