Commit 59cf3b1cabf87d77266297a48484f023856b43c3

Authored by 王军波
1 parent fed1d0a3

播放,全屏

LiveVideoCloud.xcodeproj/project.pbxproj
... ... @@ -269,6 +269,7 @@
269 269 D2EBC8931F0241B900F198FB /* CNLiveChatManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2EBC8911F0241B500F198FB /* CNLiveChatManager.framework */; };
270 270 D2EBC8941F0241B900F198FB /* CNLiveChatManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2EBC8911F0241B500F198FB /* CNLiveChatManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
271 271 D2EBC8961F0241BC00F198FB /* CNLiveMsgTools.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D2EBC88F1F0241AD00F198FB /* CNLiveMsgTools.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
  272 + D2EBC8991F025D4700F198FB /* LVCVodPlayerFullController.m in Sources */ = {isa = PBXBuildFile; fileRef = D2EBC8981F025D4700F198FB /* LVCVodPlayerFullController.m */; };
272 273 /* End PBXBuildFile section */
273 274  
274 275 /* Begin PBXContainerItemProxy section */
... ... @@ -832,6 +833,8 @@
832 833 D2EBC88D1F023AA400F198FB /* LVCVodPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodPlayerController.m; sourceTree = "<group>"; };
833 834 D2EBC88F1F0241AD00F198FB /* CNLiveMsgTools.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveMsgTools.framework; sourceTree = "<group>"; };
834 835 D2EBC8911F0241B500F198FB /* CNLiveChatManager.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = CNLiveChatManager.framework; sourceTree = "<group>"; };
  836 + D2EBC8971F025D4700F198FB /* LVCVodPlayerFullController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LVCVodPlayerFullController.h; sourceTree = "<group>"; };
  837 + D2EBC8981F025D4700F198FB /* LVCVodPlayerFullController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LVCVodPlayerFullController.m; sourceTree = "<group>"; };
835 838 /* End PBXFileReference section */
836 839  
837 840 /* Begin PBXFrameworksBuildPhase section */
... ... @@ -2141,6 +2144,8 @@
2141 2144 D2EBC8871F0225D900F198FB /* LVCVodPlayerListController.m */,
2142 2145 D2EBC88C1F023AA400F198FB /* LVCVodPlayerController.h */,
2143 2146 D2EBC88D1F023AA400F198FB /* LVCVodPlayerController.m */,
  2147 + D2EBC8971F025D4700F198FB /* LVCVodPlayerFullController.h */,
  2148 + D2EBC8981F025D4700F198FB /* LVCVodPlayerFullController.m */,
2144 2149 );
2145 2150 path = Controller;
2146 2151 sourceTree = "<group>";
... ... @@ -2423,6 +2428,7 @@
2423 2428 D29E81ED1E88DC5B008C9906 /* PriChatCell.m in Sources */,
2424 2429 D2029CD01E6EADE10027CD92 /* SearchPresenter.m in Sources */,
2425 2430 D2029CBE1E6EADE10027CD92 /* SDWebImagePrefetcher.m in Sources */,
  2431 + D2EBC8991F025D4700F198FB /* LVCVodPlayerFullController.m in Sources */,
2426 2432 D2A803081E80BD6F009D6F1C /* TopToolView.m in Sources */,
2427 2433 D2B7B2571E8261EF00ED084E /* ChatBarrOperation.m in Sources */,
2428 2434 D209AD6B1EC580F100D82E3B /* LVCWebViewController.m in Sources */,
... ...
LiveVideoCloud.xcodeproj/xcuserdata/cnlive.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
... ... @@ -9,45 +9,13 @@
9 9 shouldBeEnabled = "Yes"
10 10 ignoreCount = "0"
11 11 continueAfterRunningActions = "No"
12   - filePath = "LiveVideoCloud/Classes/Sections/Mine/Controllers/FeedbackViewController.m"
13   - timestampString = "520237865.304262"
  12 + filePath = "LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.m"
  13 + timestampString = "520277942.714492"
14 14 startingColumnNumber = "9223372036854775807"
15 15 endingColumnNumber = "9223372036854775807"
16   - startingLineNumber = "33"
17   - endingLineNumber = "33"
18   - landmarkName = "-viewDidLoad"
19   - landmarkType = "7">
20   - </BreakpointContent>
21   - </BreakpointProxy>
22   - <BreakpointProxy
23   - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
24   - <BreakpointContent
25   - shouldBeEnabled = "Yes"
26   - ignoreCount = "0"
27   - continueAfterRunningActions = "No"
28   - filePath = "LiveVideoCloud/Classes/Sections/Mine/Controllers/FeedbackViewController.m"
29   - timestampString = "520237929.578646"
30   - startingColumnNumber = "9223372036854775807"
31   - endingColumnNumber = "9223372036854775807"
32   - startingLineNumber = "143"
33   - endingLineNumber = "143"
34   - landmarkName = "-request"
35   - landmarkType = "7">
36   - </BreakpointContent>
37   - </BreakpointProxy>
38   - <BreakpointProxy
39   - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
40   - <BreakpointContent
41   - shouldBeEnabled = "Yes"
42   - ignoreCount = "0"
43   - continueAfterRunningActions = "No"
44   - filePath = "LiveVideoCloud/Classes/Sections/Mine/Controllers/FeedbackViewController.m"
45   - timestampString = "520237933.08285"
46   - startingColumnNumber = "9223372036854775807"
47   - endingColumnNumber = "9223372036854775807"
48   - startingLineNumber = "126"
49   - endingLineNumber = "126"
50   - landmarkName = "-request"
  16 + startingLineNumber = "287"
  17 + endingLineNumber = "287"
  18 + landmarkName = "-deviceOrientationChanged:"
51 19 landmarkType = "7">
52 20 </BreakpointContent>
53 21 </BreakpointProxy>
... ...
LiveVideoCloud/AppDelegate/AppDelegate.m
... ... @@ -44,7 +44,7 @@
44 44  
45 45 // 20170327 20170328
46 46  
47   - CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170328" name:@"20170328" portrait:@""];
  47 + CNLiveChatUserInfo *userInfo = [[CNLiveChatUserInfo alloc] initWithUserId:@"20170328" name:@"20170627" portrait:@""];
48 48 [[CNLiveChatManager sharedCNLiveChatManager] loginServer:userInfo success:^(NSString *userId) {
49 49 NSLog(@"连接服务器-----success");
50 50  
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.h
... ... @@ -10,4 +10,6 @@
10 10  
11 11 @interface LVCVodPlayerController : BaseViewController
12 12  
  13 +@property (nonatomic, strong) ProgramModel *model;
  14 +
13 15 @end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerController.m
... ... @@ -7,17 +7,621 @@
7 7 //
8 8  
9 9 #import "LVCVodPlayerController.h"
  10 +#import <CNLivePlayerSDK/CNLiveMoviePlayerController.h>
  11 +#import "LVCVodPlayerFullController.h"
10 12  
11   -@interface LVCVodPlayerController ()
  13 +typedef enum {
  14 + SwipeDirectionNone,
  15 + SwipeDirectionVertical,
  16 + SwipeDirectionHorizontal
  17 +} SwipeDirection;
  18 +
  19 +@interface LVCVodPlayerController (){
  20 +
  21 + UIButton *_backButton;
  22 + CNLiveMoviePlayerController *_player;//播放器
  23 + BOOL _isPlaying; // 判断当前播放状态
  24 + NSTimer *_autoHideTimer; // 自动隐藏时间
  25 + NSTimer *_currentTimer;// 更新当前播放时间
  26 + CGPoint _prePoint;
  27 + BOOL _status; // 状态栏是否显示
  28 + NSInteger _direction; // 屏幕方向 0正 1左 2右
  29 + BOOL _isFullScreen; //判断是否全屏
  30 + BOOL _isAppResignActive; //App状态 是否后台 YES后台 NO前台
  31 +}
  32 +
  33 +@property (nonatomic, strong) UIView *playerSuperView; //播放器背景
  34 +@property (nonatomic, strong) UIView *topView; //上方功能视图
  35 +@property (nonatomic, strong) UIView *bottomView; //下方
  36 +@property (nonatomic, strong) UILabel *videoTitle; //视频标题
  37 +@property (nonatomic, strong) UIButton *playPauseBtn; //播放暂停按钮
  38 +@property (nonatomic, strong) UILabel *currentTimeLabel; //当前时间显示
  39 +@property (nonatomic, strong) UILabel *durationLabel; //总时间
  40 +@property (nonatomic, strong) UISlider *timeSlide; //滑动
  41 +@property (nonatomic, strong) UIProgressView *bufferProgress; //缓冲
  42 +@property (nonatomic, assign) SwipeDirection swipeDirection;// 滑动方向
  43 +@property (nonatomic, strong) UISlider *volumeSlide; //声音控制
  44 +@property (nonatomic, strong) UIButton *toFullBtn;
  45 +@property (nonatomic, strong) LVCVodPlayerFullController *fullVC;
12 46  
13 47 @end
14 48  
15 49 @implementation LVCVodPlayerController
16 50  
  51 +- (void)viewWillAppear:(BOOL)animated
  52 +{
  53 + [super viewWillAppear:animated];
  54 + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
  55 + [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
  56 + self.navigationController.navigationBar.hidden = YES;
  57 +}
  58 +
  59 +- (void)viewWillDisappear:(BOOL)animated
  60 +{
  61 + [super viewWillDisappear:animated];
  62 + [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  63 + [[UIApplication sharedApplication] setStatusBarHidden: NO withAnimation:UIStatusBarAnimationNone];
  64 + self.navigationController.navigationBar.hidden = NO;
  65 +}
  66 +
17 67 - (void)viewDidLoad {
18 68 [super viewDidLoad];
  69 + [self addNotifications];
19 70  
20 71 self.view.backgroundColor = [UIColor whiteColor];
  72 + [self.view addSubview:self.playerSuperView];
  73 +}
  74 +
  75 +- (void)setModel:(ProgramModel *)model {
  76 + _model = model;
  77 +
  78 + //用来更新视频当前播放时间
  79 + _currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timeChange) userInfo:nil repeats:YES];
  80 +
  81 + [self playerInitialize];
  82 +}
  83 +
  84 +#pragma mark - 初始化播放器
  85 +- (void)playerInitialize {
  86 +
  87 + _player = [[CNLiveMoviePlayerController alloc] initVodPlayWithVId:self.model.mediaId
  88 + authSuccess:^{
  89 +
  90 + _isPlaying = YES;
  91 +
  92 + _player.view.frame = CGRectMake(0, 20, KScreenWidth, KVideoHeight);
  93 + _player.shouldAutoplay = YES;
  94 + [_player prepareToPlay];
  95 + [_playerSuperView insertSubview:_player.view atIndex:0];
  96 +
  97 + UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTap:)];
  98 + [_player.view addGestureRecognizer:singleTap];// 点击手势
  99 +
  100 + UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panRecognizerAction:)];
  101 + [_player.view addGestureRecognizer:panRecognizer];// 声音,亮度手势
  102 +
  103 + _autoHideTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(autoHideCtrlView) userInfo:nil repeats:NO];//隐藏时间
  104 +
  105 + _playPauseBtn.userInteractionEnabled = YES;
  106 + } authFailed:^(NSDictionary *errorInfo) {
  107 + NSLog(@"初始化点播播放器失败%@", errorInfo);
  108 + }];
  109 +}
  110 +
  111 +
  112 +#pragma mark - GetMethod !!!!!!!!!!!!!!!!!!!!!!!!!!!
  113 +- (UIView *)playerSuperView
  114 +{
  115 + if (!_playerSuperView) {
  116 + _playerSuperView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KVideoHeight+20)];
  117 + _playerSuperView.backgroundColor = [UIColor blackColor];
  118 + _backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 15, 35, 35)];
  119 + [_backButton setImage:[UIImage imageNamed:@"play_fanhui"] forState:UIControlStateNormal];
  120 + [_backButton setImage:[UIImage imageNamed:@"fanhui_focused"] forState:UIControlStateHighlighted];
  121 + [_backButton addTarget:self action:@selector(clickToBack) forControlEvents:UIControlEventTouchUpInside];
  122 +
  123 + [_playerSuperView addSubview:self.topView];
  124 + [_playerSuperView addSubview:self.bottomView];
  125 + [_playerSuperView addSubview:_backButton];
  126 + }
  127 + return _playerSuperView;
  128 +}
  129 +
  130 +- (UILabel *)videoTitle { // 视频标题
  131 + if (!_videoTitle) {
  132 + _videoTitle = [[UILabel alloc] initWithFrame:CGRectMake(44, 15, KScreenWidth - 100, 35)];
  133 + _videoTitle.font = [UIFont systemFontOfSize:16];
  134 + _videoTitle.textColor = [UIColor whiteColor];
  135 + if ([self.model.subTitle isEqualToString:@""]) {
  136 + _videoTitle.text = self.model.title;
  137 + } else {
  138 + _videoTitle.text = self.model.subTitle;
  139 + }
  140 + }
  141 + return _videoTitle;
  142 +}
  143 +
  144 +- (UIView *)topView { // 播放器顶部功能条
  145 +
  146 + if (!_topView) {
  147 + _topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenHeight, 55)];
  148 + _topView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
  149 + [_topView addSubview:self.videoTitle];
  150 + _topView.hidden = YES;
  151 + }
  152 + return _topView;
  153 +}
  154 +
  155 +- (UIView *)bottomView { // 播放器底部功能条
  156 +
  157 + if (!_bottomView) {
  158 + _bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, KVideoHeight - 20, KScreenWidth, 40)];
  159 + _bottomView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
  160 + [_bottomView addSubview:self.playPauseBtn];
  161 + [_bottomView addSubview:self.currentTimeLabel];
  162 + [_bottomView addSubview:self.durationLabel];
  163 + [_bottomView addSubview:self.bufferProgress];
  164 + [_bottomView addSubview:self.timeSlide];
  165 + [_bottomView addSubview:self.toFullBtn];
  166 + }
  167 + return _bottomView;
  168 +}
  169 +
  170 +- (UIButton *)playPauseBtn { //播放暂停按钮
  171 + if (!_playPauseBtn) {
  172 + _playPauseBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  173 + _playPauseBtn.frame = CGRectMake(0, 0, 40, 40);
  174 + [_playPauseBtn addTarget:self action:@selector(playPause) forControlEvents:UIControlEventTouchUpInside];
  175 + [_playPauseBtn setImage:[UIImage imageNamed:@"play_bofang"] forState:UIControlStateNormal];
  176 + _playPauseBtn.userInteractionEnabled = NO;
  177 + }
  178 + return _playPauseBtn;
  179 +}
  180 +
  181 +- (UILabel *)currentTimeLabel { //当前播放时间
  182 + if (!_currentTimeLabel) {
  183 + _currentTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 55, 40)];
  184 + _currentTimeLabel.textColor = [UIColor whiteColor];
  185 + _currentTimeLabel.font = [UIFont systemFontOfSize:12];
  186 + [_currentTimeLabel setText:[NSString stringWithFormat:@"00:00:00"]];
  187 + }
  188 + return _currentTimeLabel;
  189 +}
  190 +
  191 +- (UILabel *)durationLabel { //总时长
  192 + if (!_durationLabel) {
  193 + _durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(KScreenWidth - 95, 0, 55, 40)];
  194 + _durationLabel.textColor = [UIColor whiteColor];
  195 + _durationLabel.font = [UIFont systemFontOfSize:12];
  196 + [_durationLabel setText:[NSString stringWithFormat:@"00:00:00"]];
  197 + }
  198 + return _durationLabel;
  199 +}
  200 +
  201 +- (UISlider *)timeSlide { // 滑动
  202 + if (!_timeSlide) {
  203 + _timeSlide = [[UISlider alloc] initWithFrame:CGRectMake(95, 0, KScreenWidth - 190, 40)];
  204 + [_timeSlide setMinimumTrackTintColor:[UIColor redColorCNLive]];
  205 + [_timeSlide setMaximumTrackTintColor:[UIColor clearColor]];
  206 + [_timeSlide addTarget:self action:@selector(beginScrubbing) forControlEvents:UIControlEventTouchDown];
  207 + [_timeSlide addTarget:self action:@selector(endScrubbing) forControlEvents:UIControlEventTouchUpInside];
  208 + [_timeSlide addTarget:self action:@selector(endScrubbing) forControlEvents:UIControlEventTouchUpOutside];
  209 + }
  210 + return _timeSlide;
  211 +}
  212 +
  213 +- (UIProgressView *)bufferProgress { // 缓冲
  214 + if (!_bufferProgress) {
  215 + _bufferProgress = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
  216 + _bufferProgress.frame = CGRectMake(111, 19, KScreenWidth - 111- 55-40, 1);
  217 + _bufferProgress.trackTintColor = [UIColor whiteColor];
  218 + _bufferProgress.progressTintColor = [UIColor grayColor];
  219 + _bufferProgress.progress = 0;
  220 + }
  221 + return _bufferProgress;
  222 +}
  223 +
  224 +- (UISlider *)volumeSlide //音量改变 不直接展示MPVolumeView,而是获取它的子视图slide来改变系统音量
  225 +{
  226 + if (!_volumeSlide) {
  227 + MPVolumeView *slide = [[MPVolumeView alloc] init];
  228 + for (UIView *view in [slide subviews]) {
  229 + if ([view isKindOfClass:[UISlider class]]) {
  230 + _volumeSlide = (UISlider *)view;
  231 + }
  232 + }
  233 + }
  234 + return _volumeSlide;
  235 +}
  236 +
  237 +- (UIButton *)toFullBtn //全屏按钮
  238 +{
  239 + if (!_toFullBtn) {
  240 + _toFullBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  241 + [_toFullBtn setImage:[UIImage imageNamed:@"play_fangda_default"] forState:UIControlStateNormal];
  242 + [_toFullBtn setImage:[UIImage imageNamed:@"play_fangda_focused"] forState:UIControlStateHighlighted];
  243 + _toFullBtn.frame = CGRectMake(KScreenWidth - 40, 2.5, 35, 35);
  244 + [_toFullBtn addTarget:self action:@selector(clickButtonToFull) forControlEvents:UIControlEventTouchUpInside];
  245 + }
  246 + return _toFullBtn;
  247 +}
  248 +
  249 +- (LVCVodPlayerFullController *)fullVC { //全屏播放器
  250 + if (!_fullVC) {
  251 + _fullVC = [[LVCVodPlayerFullController alloc] init];
  252 + }
  253 + return _fullVC;
  254 +}
  255 +
  256 +#pragma mark - Action !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  257 +- (void)addNotifications {
  258 +
  259 + // 设备方向监听通知
  260 + [[NSNotificationCenter defaultCenter] addObserver:self
  261 + selector:@selector(deviceOrientationChanged:)
  262 + name:UIDeviceOrientationDidChangeNotification
  263 + object:nil];
  264 +
  265 + //视频播放状态改变
  266 + [[NSNotificationCenter defaultCenter] addObserver:self
  267 + selector:@selector(moviePlayBackStateDidChange:)
  268 + name:MPMoviePlayerPlaybackStateDidChangeNotification
  269 + object:nil];
  270 +
  271 + [[NSNotificationCenter defaultCenter] addObserver:self
  272 + selector:@selector(appResignActive)
  273 + name:UIApplicationWillResignActiveNotification
  274 + object:nil];
  275 +
  276 + [[NSNotificationCenter defaultCenter] addObserver:self
  277 + selector:@selector(appBecomeActive)
  278 + name:UIApplicationDidBecomeActiveNotification
  279 + object:nil];
  280 +}
  281 +
  282 +#pragma mark - 屏幕旋转通知监听
  283 +- (void)deviceOrientationChanged:(id)sender {
  284 +
  285 + if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait)
  286 + {
  287 + if (_direction == 0 || _isAppResignActive) {
  288 + return;
  289 + }
  290 +
  291 + [self clickToBack];
  292 +
  293 + }else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft)
  294 + {
  295 + // 1 左
  296 + if (_direction == 1 || _direction == 2 || _isAppResignActive) {
  297 + return;
  298 + } else {
  299 + _direction = 1;
  300 + [self scrollToFull];
  301 + }
  302 +
  303 + }else if([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
  304 + {
  305 + // 2 右
  306 + if (_direction == 2 || _direction == 1 || _isAppResignActive) {
  307 + return;
  308 + } else {
  309 + _direction = 2;
  310 + [self scrollToFull];
  311 + }
  312 + }
  313 +}
  314 +
  315 +#pragma mark - App 状态通知
  316 +- (void)appResignActive {
  317 +
  318 + _isAppResignActive = YES;
  319 + [_player pause];
  320 +}
  321 +
  322 +- (void)appBecomeActive {
  323 +
  324 + _isAppResignActive = NO;
  325 + [_player play];
  326 +}
  327 +
  328 +- (void)clickButtonToFull {
  329 +
  330 + _direction = 1;
  331 + [self scrollToFull];
  332 +}
  333 +
  334 +- (void)scrollToFull {
  335 +
  336 + CGFloat angle = _direction == 2 ? M_PI_2 : -M_PI_2;
  337 +
  338 + [self presentViewController:self.fullVC animated:NO completion:^{
  339 +
  340 + [self.playerSuperView removeFromSuperview];
  341 + [self.fullVC.view addSubview:self.playerSuperView];
  342 +
  343 + [self toFullFrameChange];
  344 +
  345 + self.playerSuperView.transform = CGAffineTransformMakeRotation(angle);
  346 + [UIView animateWithDuration:0.3 animations:^{
  347 + self.playerSuperView.transform = CGAffineTransformMakeRotation(0);
  348 + }];
  349 + }];
  350 +}
  351 +
  352 +- (void)toFullFrameChange {
  353 +
  354 + _isFullScreen = YES;
  355 + _toFullBtn.hidden = YES;
  356 + _topView.hidden = NO;
  357 + [_playerSuperView setFrame:CGRectMake(0.0f, 0.0f, KScreenHeight, KScreenWidth)];
  358 + _player.view.frame = _playerSuperView.bounds;
  359 + _bottomView.frame = CGRectMake(0, KScreenWidth - 55, KScreenHeight, 55);
  360 + _durationLabel.x = KScreenHeight - 55;
  361 + _timeSlide.width = KScreenHeight - 150;
  362 + _bufferProgress.width = KScreenHeight - 111 - 55;
  363 +}
  364 +
  365 +- (void)clickToBack { //退出
  366 +
  367 + if (_isFullScreen) {
  368 +
  369 + CGFloat angle = _direction == 2 ? -M_PI_2 : M_PI_2;
  370 + [self.fullVC dismissViewControllerAnimated:NO completion:^{
  371 +
  372 + [self.playerSuperView removeFromSuperview];
  373 + [self.view insertSubview:self.playerSuperView atIndex:0];
  374 + [self fromFullToNormal];
  375 + self.playerSuperView.transform = CGAffineTransformMakeRotation(angle);
  376 + [UIView animateWithDuration:0.3 animations:^{
  377 + self.playerSuperView.transform = CGAffineTransformMakeRotation(0);
  378 + }];
  379 + }];
  380 + } else {
  381 +
  382 + [_player stop];
  383 + [_autoHideTimer invalidate];
  384 + _autoHideTimer = nil;
  385 + [_currentTimer invalidate];
  386 + _currentTimer = nil;
  387 + [[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
  388 + [_playerSuperView removeFromSuperview];
  389 + [self.navigationController popViewControllerAnimated:YES];
  390 + }
  391 +}
  392 +
  393 +- (void)fromFullToNormal {
  394 +
  395 + _isFullScreen = NO;
  396 + _toFullBtn.hidden = NO;
  397 + _topView.hidden = YES;
  398 +
  399 + _playerSuperView.bounds = CGRectMake(0, 0, KScreenWidth, KVideoHeight + 20);
  400 + CGPoint backPoint = CGPointMake(KScreenWidth * 0.5, KVideoHeight * 0.5 + 10);
  401 + _playerSuperView.center = backPoint;
  402 + _player.view.frame = CGRectMake(0, 20, KScreenWidth, KVideoHeight);
  403 + _bottomView.frame = CGRectMake(0, KVideoHeight - 20, KScreenWidth, 40);
  404 + _durationLabel.x = KScreenWidth - 95;
  405 + _timeSlide.width = KScreenWidth - 190;
  406 + _bufferProgress.width = KScreenWidth - 111- 55-40;
  407 + _direction = 0;
  408 +}
  409 +
  410 +- (void)playPause { //播放暂停
  411 +
  412 + _isPlaying = _isPlaying == YES ? NO : YES;
  413 +
  414 + if (_player.isPlaying) {
  415 + [_player pause];
  416 + [_autoHideTimer invalidate];
  417 + } else {
  418 + [_player play];
  419 + _autoHideTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(autoHideCtrlView) userInfo:nil repeats:NO];
  420 + }
  421 +}
  422 +
  423 +- (void)autoHideCtrlView { //自动隐藏上下功能视图
  424 + [UIView animateWithDuration:0.3 animations:^{
  425 + self.topView.alpha = 0;
  426 + self.bottomView.alpha = 0;
  427 + _status = YES;
  428 + if (_isFullScreen) {
  429 + [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
  430 + }
  431 + }];
  432 +}
  433 +
  434 +- (void)singleTap:(UIGestureRecognizer *)tap { //单击手势
  435 +
  436 + if (_isPlaying) {
  437 + [_autoHideTimer invalidate];
  438 + _autoHideTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(autoHideCtrlView) userInfo:nil repeats:NO];
  439 + }
  440 + [UIView animateWithDuration:0.5 animations:^{
  441 + self.topView.alpha = self.topView.alpha == 0 ? 1 : 0;
  442 + self.bottomView.alpha = self.bottomView.alpha == 0 ? 1 : 0;
  443 + _status = self.topView.alpha == 0 ? YES : NO;
  444 +
  445 + if (_isFullScreen) {
  446 + [[UIApplication sharedApplication] setStatusBarHidden:_status withAnimation:UIStatusBarAnimationFade];
  447 + }
  448 + }];
  449 +}
  450 +
  451 +- (void)timeChange { // 更新当前播放时间
  452 +
  453 + _bufferProgress.progress = _player.playableDuration/_player.duration;
  454 + if (!_player.isPreparedToPlay) {
  455 + return;
  456 + }
  457 + _timeSlide.value = _player.currentPlaybackTime;
  458 + _timeSlide.maximumValue = _player.duration;
  459 +
  460 + // 当前播放时间
  461 + NSInteger currentSeconds = (NSInteger)_player.currentPlaybackTime;
  462 + NSInteger seconds = currentSeconds % 60;
  463 + NSInteger minutes = currentSeconds / 60;
  464 + NSInteger hours = minutes / 60;
  465 +
  466 + // 总时长
  467 + NSInteger durationall = (NSInteger)_player.duration;
  468 + NSInteger durationSeconds = durationall % 60;
  469 + NSInteger durationMinutes = durationall / 60;
  470 + NSInteger durationHours = durationMinutes / 60;
  471 +
  472 + // 当前时间
  473 + _currentTimeLabel.text = [NSString stringWithFormat:@"%02ld:%02ld:%02ld", (long)hours, (long)minutes%60, (long)seconds];
  474 + // 总时长
  475 + _durationLabel.text = [NSString stringWithFormat:@"%02ld:%02ld:%02ld", (long)durationHours, (long)durationMinutes%60, (long)durationSeconds];
  476 +}
  477 +
  478 +// 滑动监听方法
  479 +- (void)beginScrubbing {
  480 + [_player pause];
  481 + [_currentTimer invalidate];
  482 + [_autoHideTimer invalidate];
  483 +}
  484 +
  485 +- (void)endScrubbing {
  486 + [_player setCurrentPlaybackTime:_timeSlide.value];
  487 + [_player play];
  488 + _currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timeChange) userInfo:nil repeats:YES];
  489 + _autoHideTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(autoHideCtrlView) userInfo:nil repeats:NO];
  490 +}
  491 +
  492 +- (void)panRecognizerAction:(UIPanGestureRecognizer *)panRecognizer { // 声音拖拽方法
  493 +
  494 + switch (panRecognizer.state) {
  495 + case UIGestureRecognizerStateBegan:
  496 + {
  497 + self.swipeDirection = SwipeDirectionNone;
  498 + _prePoint = [panRecognizer locationInView:_playerSuperView];
  499 + }
  500 + break;
  501 + case UIGestureRecognizerStateChanged:
  502 + {
  503 + CGPoint currp = [panRecognizer locationInView:_playerSuperView];
  504 + CGPoint distance = [panRecognizer translationInView:_playerSuperView];
  505 + CGFloat xLength = currp.x-_prePoint.x;
  506 + CGFloat yLength = _prePoint.y-currp.y;
  507 +
  508 + NSLog(@"x:%f y:%f d:%f",xLength,yLength,distance.x);
  509 + _prePoint = currp;
  510 +
  511 + switch (self.swipeDirection) {
  512 + case SwipeDirectionNone:
  513 + if (fabs(xLength)>fabs(yLength)) {
  514 + // 水平
  515 + self.swipeDirection = SwipeDirectionHorizontal;
  516 + }else{
  517 + // 垂直
  518 + self.swipeDirection = SwipeDirectionVertical;
  519 + }
  520 + break;
  521 + case SwipeDirectionVertical:
  522 + {
  523 + CGFloat middle = 0;
  524 + if (_isFullScreen) {
  525 + middle = KScreenHeight*0.5;
  526 + } else {
  527 + middle = KScreenWidth*0.5;
  528 + }
  529 + if (_prePoint.x < middle) {
  530 + [self swipeVerticalVolume:yLength];
  531 + } else {
  532 + [self swipeVerticalBrightness:yLength];
  533 + }
  534 + }
  535 + break;
  536 + case SwipeDirectionHorizontal:
  537 + {
  538 + [_player pause];
  539 + [_currentTimer invalidate];
  540 + [_autoHideTimer invalidate];
  541 + _timeSlide.value += xLength/KScreenHeight*_player.duration;
  542 + }
  543 + break;
  544 + default:
  545 + break;
  546 + }
  547 + }
  548 + break;
  549 + case UIGestureRecognizerStateEnded:
  550 + case UIGestureRecognizerStateCancelled:
  551 + case UIGestureRecognizerStateFailed:
  552 + {
  553 + if (self.swipeDirection == SwipeDirectionHorizontal) {
  554 + [_player setCurrentPlaybackTime:_timeSlide.value];
  555 + [_player play];
  556 + _currentTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timeChange) userInfo:nil repeats:YES];
  557 + _autoHideTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(autoHideCtrlView) userInfo:nil repeats:NO];
  558 + }
  559 + }
  560 + break;
  561 +
  562 + default:
  563 + break;
  564 + }
  565 +}
  566 +
  567 +- (void)swipeVerticalVolume:(CGFloat)length { //纵向滑动手势声音
  568 +
  569 + self.volumeSlide.value += length/KScreenWidth;
  570 +}
  571 +
  572 +- (void)swipeVerticalBrightness:(CGFloat)length { //纵向滑动手势亮度
  573 +
  574 + [UIScreen mainScreen].brightness += length/KScreenWidth;
  575 +}
  576 +
  577 +- (void)moviePlayBackStateDidChange:(NSNotification *)notification { //播放状态通知
  578 + if (_player) {
  579 +
  580 + switch (_player.playbackState) {
  581 + case MPMoviePlaybackStateStopped: {
  582 + [self changePlayBtnStatus:NO];
  583 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateStopped");
  584 + break;
  585 + }
  586 + case MPMoviePlaybackStatePlaying: {
  587 + [self changePlayBtnStatus:YES];
  588 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePlaying");
  589 + break;
  590 + }
  591 + case MPMoviePlaybackStatePaused:
  592 + [self changePlayBtnStatus:NO];
  593 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStatePaused");
  594 + break;
  595 + case MPMoviePlaybackStateInterrupted:
  596 + [self changePlayBtnStatus:NO];
  597 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateInterrupted");
  598 + break;
  599 + case MPMoviePlaybackStateSeekingForward:
  600 + [self changePlayBtnStatus:NO];
  601 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingForward");
  602 + break;
  603 + case MPMoviePlaybackStateSeekingBackward:
  604 + [self changePlayBtnStatus:NO];
  605 + NSLog(@"moviePlayBackStateDidChange : MPMoviePlaybackStateSeekingBackward");
  606 + break;
  607 + default:
  608 + [self changePlayBtnStatus:NO];
  609 + NSLog(@"moviePlayBackStateDidChange : %ld", _player.playbackState);
  610 + break;
  611 + }
  612 + }
  613 +}
  614 +
  615 +- (void)changePlayBtnStatus:(BOOL)playing { //改变播放暂停按钮图片
  616 + if (playing) {
  617 + [_playPauseBtn setImage:[UIImage imageNamed:@"play_bofang"] forState:UIControlStateNormal];
  618 + } else {
  619 + [_playPauseBtn setImage:[UIImage imageNamed:@"play_zanting"] forState:UIControlStateNormal];
  620 + }
  621 +}
  622 +
  623 +- (void)dealloc {
  624 + NSLog(@"dealloc");
21 625 }
22 626  
23 627 - (void)didReceiveMemoryWarning {
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerFullController.h 0 → 100644
  1 +//
  2 +// LVCVodPlayerFullController.h
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/6/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import <UIKit/UIKit.h>
  10 +
  11 +@interface LVCVodPlayerFullController : UIViewController
  12 +
  13 +@property (nonatomic, strong) ProgramModel *model;
  14 +
  15 +@end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerFullController.m 0 → 100644
  1 +//
  2 +// LVCVodPlayerFullController.m
  3 +// LiveVideoCloud
  4 +//
  5 +// Created by cnliveJunBo on 17/6/27.
  6 +// Copyright © 2017年 cnlive. All rights reserved.
  7 +//
  8 +
  9 +#import "LVCVodPlayerFullController.h"
  10 +
  11 +@interface LVCVodPlayerFullController ()
  12 +
  13 +@end
  14 +
  15 +@implementation LVCVodPlayerFullController
  16 +
  17 +- (void)viewWillAppear:(BOOL)animated {
  18 + [super viewWillAppear:animated];
  19 +
  20 + [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
  21 +
  22 + [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
  23 +}
  24 +
  25 +- (void)viewDidLoad {
  26 + [super viewDidLoad];
  27 +
  28 + self.view.backgroundColor = [UIColor whiteColor];
  29 +}
  30 +
  31 +- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
  32 + return UIInterfaceOrientationMaskLandscape;
  33 +}
  34 +
  35 +- (BOOL)shouldAutorotate {
  36 + return YES;
  37 +}
  38 +
  39 +- (void)dealloc {
  40 + NSLog(@">>>>>>>>>>>>>>>>>> fullView dealloc");
  41 +}
  42 +
  43 +- (void)didReceiveMemoryWarning {
  44 + [super didReceiveMemoryWarning];
  45 + // Dispose of any resources that can be recreated.
  46 +}
  47 +
  48 +@end
... ...
LiveVideoCloud/Classes/Sections/homeSections/Controller/LVCVodPlayerListController.m
... ... @@ -98,6 +98,7 @@ static NSString *vodCellId = @&quot;vodCellId&quot;;
98 98 [tableView deselectRowAtIndexPath:indexPath animated:NO];
99 99  
100 100 LVCVodPlayerController *vc = [[LVCVodPlayerController alloc] init];
  101 + vc.model = _programArrayM[indexPath.row];
101 102 [self.navigationController pushViewController:vc animated:YES];
102 103 }
103 104  
... ...
LiveVideoCloud/animation.xcassets/play_bofang.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "play_bofang.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/animation.xcassets/play_bofang.imageset/play_bofang.png 0 → 100644

2.01 KB

LiveVideoCloud/animation.xcassets/play_fangda_default.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "play_fangda_default.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/animation.xcassets/play_fangda_default.imageset/play_fangda_default.png 0 → 100644

1.27 KB

LiveVideoCloud/animation.xcassets/play_fangda_focused.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "play_fangda_focused.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/animation.xcassets/play_fangda_focused.imageset/play_fangda_focused.png 0 → 100644

1.28 KB

LiveVideoCloud/animation.xcassets/play_fanhui.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "play_fanhui.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/animation.xcassets/play_fanhui.imageset/play_fanhui.png 0 → 100644

1.47 KB

LiveVideoCloud/animation.xcassets/play_zanting.imageset/Contents.json 0 → 100644
  1 +{
  2 + "images" : [
  3 + {
  4 + "idiom" : "universal",
  5 + "filename" : "play_zanting.png",
  6 + "scale" : "1x"
  7 + },
  8 + {
  9 + "idiom" : "universal",
  10 + "scale" : "2x"
  11 + },
  12 + {
  13 + "idiom" : "universal",
  14 + "scale" : "3x"
  15 + }
  16 + ],
  17 + "info" : {
  18 + "version" : 1,
  19 + "author" : "xcode"
  20 + }
  21 +}
0 22 \ No newline at end of file
... ...
LiveVideoCloud/animation.xcassets/play_zanting.imageset/play_zanting.png 0 → 100644

2.24 KB