YBPlayerRotationManage
说明:
播放器自动全屏控制,简单到极致,两行代码搞定
Installation
YBPlayerRotationManage is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'YBPlayerRotationManage'
Usage
1、在播放器内部添加成员变量,并初始化,传入播放器旋转的view和播放器所承载的view. 特别提醒: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];
}
}
然后就完成了,欧耶!!!自带旋转监听,全自动旋转播放器完成
Author
[email protected], [email protected]
License
YBPlayerRotationManage is available under the MIT license. See the LICENSE file for more info.