ijkplayer 集成

ijkplayer下載地址: https://github.com/Bilibili/ijkplayer

1.解壓后,進入ijkplayer-master文件夾,執行腳本 ./init-ios.sh

2.進入ios文件夾,執行?./compile-ffmpeg.sh clean 和?./compile-ffmpeg.sh all 直至結束

3.集成ijkplayer

1)?直接導入工程IJKMediaPlayer.xcodeproj

2) 打包IJKMediaFramework.framework使用

打開IJKMediaPlayer.xcodeproj 工程,edit scheme? -> release,分別選擇模擬器和真機編譯

編譯后在Finder中打開,將模擬器版本和真機版本的framework合并。


lipo -create "真機版本路徑" "模擬器版本路徑" -output "合并后的文件路徑"

比如我這里先導到桌面上:

lipo -create "/Users/lichanglai/Desktop/Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework" "/Users/lichanglai/Desktop/Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework" -output "/Users/lichanglai/Desktop/IJKMediaFramework"

合并后的IJKMediaFramework把原來的真機版本IJKMediaFramework替換掉,則IJKMediaFramework.framework文件就是我們需要的。

4.使用framework時,導入工程,并添加依賴即可。


使用:

//? ? //網絡視頻

? ? self.url = [NSURL URLWithString:@"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"];

? ? _player = [[IJKAVMoviePlayerController alloc] initWithContentURL:self.url];


? ? //直播視頻

//? ? self.url = [NSURL URLWithString:@"http://live.hkstv.hk.lxdns.com/live/hks/playlist.m3u8"];

//? ? _player = [[IJKFFMoviePlayerController alloc] initWithContentURL:self.url withOptions:nil];


? ? UIView*playerView = [self.playerview];


? ? UIView *displayView = [[UIView alloc] initWithFrame:CGRectMake(0, 50, self.view.bounds.size.width, 180)];

? ? self.PlayerView= displayView;

? ? self.PlayerView.backgroundColor = [UIColor blackColor];

? ? [self.view addSubview:self.PlayerView];


? ? playerView.frame=self.PlayerView.bounds;

? ? playerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;


? ? [self.PlayerViewinsertSubview:playerViewatIndex:1];

? ? [_player setScalingMode:IJKMPMovieScalingModeAspectFill];

參考:http://www.lxweimin.com/p/1f06b27b3ac0

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容