“你會做直播嗎巾陕?”。也許在面試中面試官會經(jīng)常這么問菠剩。不過你看了這篇文章,你就可以非常自信地說“我會耻煤,我可以做具壮!”。該Demo錄屏視頻地址:http://t.cn/RiUQLoP 哈蝇,歡迎查看棺妓!
一、 下載ijkplayer炮赦,GitHub地址:https://github.com/Bilibili/ijkplayer
打開ijkplayer-master文件目錄如下:
按照這篇文章http://www.reibang.com/p/1f06b27b3ac0 一步一步集成IJKMediaFramework.framework并導(dǎo)入以下系統(tǒng)庫:
AudioToolbox.framework
CoreGraphics.framework
CoreMedia.framework
CoreVideo.framework
libbz2.tbd
libz.tbd
MediaPlayer.framework
MobileCoreServices.framework
OpenGLES.framework
QuartzCore.framework
VideoToolbox.framework
二怜跑、設(shè)置播放直播
IJKFFOptions *options = [IJKFFOptions optionsByDefault];
[options setPlayerOptionIntValue:1 forKey:@"videotoolbox"];
[options setPlayerOptionIntValue:29.97 forKey:@"r"];
[options setPlayerOptionIntValue:512 forKey:@"vol"];
IJKFFMoviePlayerController *moviePlayer = [[IJKFFMoviePlayerController alloc] initWithContentURLString:_curModel.flv withOptions:options];
moviePlayer.view.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
moviePlayer.scalingMode = IJKMPMovieScalingModeAspectFill;
moviePlayer.shouldAutoplay = NO;
moviePlayer.shouldShowHudView = NO;
[self.contentView addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
三、進(jìn)行錄播
[[LFLiveSession alloc] initWithAudioConfiguration:[LFLiveAudioConfiguration defaultConfiguration] videoConfiguration:[LFLiveVideoConfiguration defaultConfigurationForQuality:LFLiveVideoQuality_Medium2] liveType:LFLiveRTMP];
四吠勘、直播的功能的實現(xiàn)很簡單性芬,主要是細(xì)節(jié)問題。如聊天剧防、點(diǎn)贊植锉、彈幕、送小禮物等等峭拘。直播由于太火了俊庇,所以也出現(xiàn)了很多好的直播框架狮暑,這篇文章簡述了幾個直播框架還不錯(http://www.reibang.com/p/5ad5b68606bb ),非常值得學(xué)習(xí)辉饱。
如有需要該項目源碼的搬男,記得打賞哦。