代码库> 音频视频> 轻量级视频播放器
轻量级视频播放器
关注
查看次数:7158 下载次数:8
上传时间:2015-06-19 大小:
KrVideoPlayerPlus
KRVideoPlayer
根据36Kr开源的KRVideoPlayer 进行修改和补充实现一个轻量级的视频播放器,满足大部分视频播放需求

链接地址:KRVideoPlayer
必要框架
MediaPlayer.framework

AVFoundation.framework

效果
KRVideoPlayer

咋使
在需要使用的控制器内引入

#import "KrVideoPlayerController.h"

@interface ViewController ()
@property (nonatomic, strong) KrVideoPlayerController  *videoController;
@end

@implementation ViewController

- (void)viewDidLoad {
   [super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
   [self playVideo];
}
- (void)playVideo{
  NSURL *url = [NSURL URLWithString:@"http://krtv.qiniudn.com/150522nextapp"];
  [self addVideoPlayerWithURL:url];
}

- (void)addVideoPlayerWithURL:(NSURL *)url{
  if (!self.videoController) {
    CGFloat width = [UIScreen mainScreen].bounds.size.width;
    self.videoController = [[KrVideoPlayerController alloc] initWithFrame:CGRectMake(0, 64, width, width*(9.0/16.0))];
    __weak typeof(self)weakSelf = self;
    [self.videoController setDimissCompleteBlock:^{
      weakSelf.videoController = nil;
    }];
    [self.videoController setWillBackOrientationPortrait:^{
      [weakSelf toolbarHidden:NO];
    }];
    [self.videoController setWillChangeToFullscreenMode:^{
      [weakSelf toolbarHidden:YES];
    }];
    [self.view addSubview:self.videoController.view];
  }
    self.videoController.contentURL = url;
}



小知识
隐藏navigation tabbar 电池栏

设置这个你懂的

View controller-based status bar appearance NO


- (void)toolbarHidden:(BOOL)Bool{
    self.navigationController.navigationBar.hidden = Bool;
    self.tabBarController.tabBar.hidden = Bool;
    [[UIApplication sharedApplication] setStatusBarHidden:Bool withAnimation:UIStatusBarAnimationFade];
}



后面有时间会加入其他小功能 音量调整,滑动快进 啥的。。基于KRVideoplayer打造,

附件较大,请在此处下载:https://github.com/835239104/KrVideoPlayerPlus.git
收藏
我来说两句
发表评论
您还没有登录!请登录注册
所有评论(0


下载过该代码的还下载了
综合评论
提示
sina weixin mail 回到顶部