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];
参考:https://www.jianshu.com/p/1f06b27b3ac0