YBPlayerRotationManage 0.1.1

YBPlayerRotationManage 0.1.1

ethanbing维护。



YBPlayerRotationManage

CI Status Version License Platform

说明:

播放器自动全屏控制,简洁至极,仅需两行代码即可实现

安装

YBPlayerRotationManage可以通过CocoaPods获取。要安装它,只需将以下行添加到Podfile中即可

pod 'YBPlayerRotationManage'

用法

1、在播放器内部添加成员变量,并进行初始化,传入播放器旋转的视图和播放器所承载的视图。特别提醒:RotateView不能使用Masonry布局,需要使用frame布局,因为内部是通过frame修改大小。

@property (nonatomic, strong) YBPlayerRotationManage *rotationManage;
- (void)setupRotationManage
{
    self.rotationManage = [[YBPlayerRotationManage alloc] initWithRotateView:self containerView:self.superview];
    __weak typeof(self) weakSelf = self;
    self.rotationManage.orientationWillChange = ^(YBPlayerRotationManage * _Nonnull observer, BOOL isFullScreen) {
        //方向将要改变
    };
    self.rotationManage.orientationDidChanged = ^(YBPlayerRotationManage * _Nonnull observer, BOOL isFullScreen) {
        //方向已经改变
//        weakSelf.fullScreen = isFullScreen;
    };
}

2、添加全屏和小屏切换,例如:

- (void)fullBtnClick:(UIButton *)btn
{
    if (btn.selected) {
        [self.rotationManage enterLandscapeFullScreen:UIInterfaceOrientationPortrait];
    }else{
        [self.rotationManage enterLandscapeFullScreen:UIInterfaceOrientationLandscapeRight];
    }
}

然后就完成了,欧耶!!!自带旋转监听,全自动旋转播放器完成

作者

[email protected][email protected]

许可

YBPlayerRotationManage开源协议为MIT许可。请参阅LICENSE文件获取更多信息。