Latest 0.1.0
Homepage https://github.com/BernardChina/BCPlayer
License MIT
Platforms ios 7.0, requires ARC
Dependencies Masonry
Frameworks UIKit, AVFoundation, MobileCoreServices, Foundation
Authors

BCPlayer

BCPlayer实现了几种播放模式。

  • 边播边缓存
  • 先缓存再播放
  • 播放不缓存

除了基本的mp4并且支持hls,m3u8格式资源。

安装

可以通过CocoaPods安装
在您的Podfile文件中添加

pod 'BCPlayer'

然后使用如下命令安装

pod install

或者

pod update

用法

BCPlayerDelegate监听播放的进度和播放完成或者错误的回调

/**
 播放完成调用此方法

 @param player 当前的player
 @param error 如果播放过程中有错误,回调返回error
 */
- (void)BCVideoPlayer:(BCVideoPlayer *)player didCompleteWithError:(NSError *)error;

/**
 返回播放进度

 @param player 当前的player
 @param progress 播放进度
 */
- (void)BCVideoPlayer:(BCVideoPlayer *)player withProgress:(double)progress currentTime:(double)current totalTime:(double)totalTime;

播放的类型

typedef NS_ENUM(NSInteger, NBPlayerCacheType) {
    NBPlayerCacheTypeNoCache,       // 不缓存,直接播放
    NBPlayerCacheTypePlayWithCache, // 边播放边缓存
    NBPlayerCacheTypePlayAfterCache, // 先缓存,再播放
    NBPlayerCacheTypePlayHLS    // 支持hls
};

使用方法很简单:

_play = [[BCVideoPlayer alloc]init];
    UIView *videoView = [[UIView alloc] init];
    [bgView addSubview:videoView];
    [videoView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view).offset(0);
        make.top.equalTo(self.view).offset(64);
        make.height.equalTo(@(250));
    }];

    _play.delegate = self;

    [_play playWithUrl:[NSURL URLWithString:self.videoUrlStr]
              showView:videoView
          andSuperView:self.view
             cacheType:NBPlayerCacheTypePlayWithCache];

TODO

未来也许会支持编解码。如果您有什么宝贵的意见或者问题,请您告诉我,感谢!一起做一款好的播放器

如果对您有帮助,请不要吝啬您的star,感谢!

Latest podspec

{
    "name": "BCPlayer",
    "version": "0.1.0",
    "summary": "BCPlayer u662fu4e00u6b3eu652fu6301u64adu653eu5728u7ebfu548cu672cu5730u8d44u6e90u7684u64adu653eu5668uff0cu53efu4ee5u8fb9u64adu8fb9u7f13u5b58uff0cu540cu65f6u4e5fu652fu6301u5148u7f13u5b58u518du64adu653euff0cu5e76u4e14u652fu6301hlsuff0cm3u8u683cu5f0fu8d44u6e90.",
    "description": "BCPlayer u662fu4e00u6b3eu652fu6301u64adu653eu5728u7ebfu548cu672cu5730u8d44u6e90u7684u64adu653eu5668uff0cu53efu4ee5u8fb9u64adu8fb9u7f13u5b58uff0cu540cu65f6u4e5fu652fu6301u5148u7f13u5b58u518du64adu653euff0cu5e76u4e14u652fu6301hlsuff0cm3u8u683cu5f0fu8d44u6e90.u5982u679cu9700u8981u8bf7star.",
    "homepage": "https://github.com/BernardChina/BCPlayer",
    "license": "MIT",
    "authors": {
        "BernardChina": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/BernardChina/BCPlayer.git",
        "tag": "v0.1.0"
    },
    "source_files": [
        "BCPlayer",
        "BCPlayer/**/*.{h,m}"
    ],
    "resources": "BCPlayer/BCPlayer.bundle",
    "frameworks": [
        "UIKit",
        "AVFoundation",
        "MobileCoreServices",
        "Foundation"
    ],
    "libraries": "xml2",
    "requires_arc": true,
    "xcconfig": {
        "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libxml2"
    },
    "dependencies": {
        "Masonry": []
    },
    "subspecs": [
        {
            "name": "CocoaHTTPServer",
            "source_files": "BCPlayer/CocoaHTTPServer/**/*.{h,m}"
        }
    ]
}

Pin It on Pinterest

Share This