Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aanaipandi22 opened this issue Oct 1, 2019 · 3 comments

Comments

@aanaipandi22
Copy link

aanaipandi22 commented Oct 1, 2019

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?

@changsanjiang
Copy link
Owner

Hi @aanaipandi22. has the table view controller rotated?

Please refer to this issue for configuration rotation. changsanjiang/SJVideoPlayer#148

@aanaipandi22
Copy link
Author

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.

@changsanjiang
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants