MCPlayerKit 0.0.6 Release
生活随笔
收集整理的這篇文章主要介紹了
MCPlayerKit 0.0.6 Release
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
"易用的播放組件,通用播放器"
當寫下2019·時,時間的匆忙撲面而來,愿每一天是美好的一天。
MCPlayerKit
MCPlayerKit 介紹
從事移動端開發以來,一直在做音視頻類的開發,蘋果的播放器基本定制型太強,需要定制在開源有kxmovie,授權的vitamio等,但層次不一,經過幾年的發展,尤其是在這兩年直播等投資熱的趨勢下,音視頻技術逐漸趨于成熟,隨便找幾個庫就能解決燃眉之急,開源的力量更進一步的推進了技術的發展,我也想寫個簡單的項目,寫出一些心得。
MCPlayerKit 是基于AVPlayer和IJKPlayer做的一款播放內核播放模塊,做IJKPlayer支持是因為AVPlayer對于一些格式協議的支持的補充,比如flv、RTMP等。
特點
- PlayerKit高度抽象出播放層和渲染層
- 耦合低,使用方便
- 有很多使用案例
Installation
Installation with CocoaPods
To integrate MCPlayerKit into your Xcode project using CocoaPods, specify it in your Podfile: 如果純使用MCPlayerKit播放功能,請用
pod 'MCPlayerKit/Core' or pod 'MCPlayerKit' 復制代碼如果需要使用高度通用UI的,可以用
pod 'MCPlayerKit/GeneralPlayerUI'復制代碼GeneralPlayerUI 樣式依賴于'MCStyle',Example/Classes/Modules/GeneralPlayer/MCPlayerGeneralController有他的詳細使用, 你可以通過json配置GeneralPlayerUI顏色、樣式、字體等。 復制代碼Run pod install
使用方法
1. 純播放功能,自定義UI
1.1 功能
a. support AVPlayer & IJKPlayerb. 統一渲染頁面 復制代碼1.2 接入代碼
- (MCPlayerKit *)playerKit {if (!_playerKit) {_playerKit = [[MCPlayerKit alloc] initWithPlayerView:self.playerView];_playerKit.playerCoreType = PlayerCoreAVPlayer;_playerKit.playerStatusDelegate = self;}return _playerKit; }//自定義渲染界面 - (MCPlayerView *)playerView {if (!_playerView) {CGFloat width = MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);CGFloat height = width * 9 / 16.0f;_playerView = [[MCPlayerView alloc] initWithFrame:CGRectMake(0, 0, width, height)];}return _playerView; } [self.playerKit playUrls:@[@"http://aliuwmp3.changba.com/userdata/video/45F6BD5E445E4C029C33DC5901307461.mp4"]]; 復制代碼2.GeneralPlayerUI 通用播放器UI
2.1 功能
a. 旋轉b. support 2018 Devicesc. loadingb. 播放中斷重試c. 用戶可以自定義UI顏色、樣式、字體大小 TODO:I. 投屏UI 復制代碼2.2 接入代碼
//顏色配置[MCStyleManager share].colorStyleDataCallback = ^NSDictionary *(void) {NSString *path = [[NSBundle mainBundle] pathForResource:@"CustomPlayerColor" ofType:@"json"];NSError *error;NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableContainers error:&error];NSAssert(!error, @"read json file error");return dictionary[@"data"];};//字體樣式配置[MCStyleManager share].fontStyleDataCallBack = ^NSDictionary *(void) {NSString *path = [[NSBundle mainBundle] pathForResource:@"CustomPlayerFont" ofType:@"json"];NSError *error;NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableContainers error:&error];NSAssert(!error, @"read json file error");return dictionary[@"data"];};//圖片等配置[MCStyleManager share].styleDataCallback = ^NSDictionary *(void) {NSString *path = [[NSBundle mainBundle] pathForResource:@"CustomPlayerStyle" ofType:@"json"];NSError *error;NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableContainers error:&error];NSAssert(!error, @"read json file error");return dictionary[@"data"];};[[MCStyleManager share] loadData];[self.view addSubview:self.playerView];[self.playerView updatePlayerPicture:@"https://avatars0.githubusercontent.com/u/3861387?s=460&v=4"];[self.playerView updateTitle:@"Skipping code signing because the target does not have an Info.plist file. (in target 'App')"]; // [self.playerKit playUrls:@[@"http://aliuwmp3.changba.com/userdata/video/45F6BD5E445E4C029C33DC5901307461.mp4"]];[self.playerKit playUrls:@[@"http://aaaaaliuwmp3.changba.com/userdata/video/45F6BD5E445E4C029C33DC5901307461.mp4"]];[self.playerView updateAction:self.playerKit];self.playerView.retryPlayUrl = ^NSString *(void) {return @"http://aliuwmp3.changba.com/userdata/video/45F6BD5E445E4C029C33DC5901307461.mp4";};- (MCPlayerKit *)playerKit {if (!_playerKit) {_playerKit = [[MCPlayerKit alloc] initWithPlayerView:self.playerView.playerView];_playerKit.playerCoreType = PlayerCoreAVPlayer;}return _playerKit;}- (MCPlayerGeneralView *)playerView {if (!_playerView) {CGFloat width = MIN([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);CGFloat height = width * 9 / 16.0f + [MCDeviceUtils xTop];_playerView = [[MCPlayerGeneralView alloc] initWithFrame:CGRectMake(0, 0, width, height)];}return _playerView;}具體參照 Example/Classes/Modules/GeneralPlayer/MCPlayerGeneralController 復制代碼2.3 Screenshot
類結構
PlayerKit --------------- 播放器核心,AVPlayer與IJKPlayer抽象-- Core Player抽象與實現以及PlayerKit播放器控制-- Extend 輔助類-- PlayerView 播放器界面父類,Custom播放器界面View必須繼承與此類GeneralPlayerUI----------- 通用播放組件UI-- Views 通用UI subviews-- MCPlayerGeneralView 通用播放界面Commen ------------------- 通用類復制代碼more
此項目會作為長期維護項目,接受各位指導。
License
These PlayerKit are available under the MIT license.
轉載于:https://juejin.im/post/5cde49b851882525b40cc845
總結
以上是生活随笔為你收集整理的MCPlayerKit 0.0.6 Release的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java中的锁原理、锁优化、CAS、AQ
- 下一篇: python 14 装饰器