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];