IJKPlayer只能支持http或者https其中之一失晴,默認支持http,如果使用https那么需要做額外的配置
獲取源碼
//獲取ijkplayer源碼
git clone https://github.com/Bilibili/ijkplayer.git ijkplayer-ios
//進入源碼目錄
cd ijkplayer-ios
//切換分支
git checkout -B latest k0.8.0
配置多種格式支持
(如果不需要多種格式可以跳過這一步)
cd config
rm module.sh
ln -s module-lite-hevc.sh module.sh
cd ..
cd ios
sh compile-ffmpeg.sh clean
獲取ffmpeg
cd ..
./init-ios.sh
https支持
(https支持的靜態(tài)文件libcrypto.a 和 libssl.a彬伦,如果不需要可以跳過這一步)
./init-ios-openssl.sh
cd ios
vim ../config/module.sh
//在打開的文件中添加一行下面一行
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-openssl"
./compile-ffmpeg.sh clean
編譯
./compile-openssl.sh all(如果不需要可以跳過這一步)
./compile-ffmpeg.sh all
配置framework
(如果不使用https跳過這一步)
用xcode打開ios目錄下的IJKMediaPlayer工程
如果不使用https蹬竖,那么直接做常規(guī)framework打包即可
如果使用https,那么需要手動添加libcrypto.a 和 libssl.a文件丈冬,默認不會添加
然后再做framework打包即可
注意:這兩個依賴庫的路徑:ijkplayer-ios/ios/build/universal/lib嘱函,只有做了上面openssl相關(guān)的操作,才可以在這個目錄下找到libcrypto.a 和 libssl.a
打包framwork
1埂蕊、配置Release模式如果下圖
2往弓、打包真機framework
如圖操作,然后編譯即可
3蓄氧、打包模擬器framework
如圖操作亮航,然后編譯即可
4、合并framework
//lipo -create 真機framework路徑 模擬器framework路徑 -output 合并路徑(這里的路徑都需要包含文件名稱)
lipo -create Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework -output IJKMediaFramework
集成framework到項目中
1匀们、導入framework
直接將framework拖入到工程中即可
2、添加下列依賴到工程
//1准给、libstdc++.tbd
//2泄朴、libz.tbd
//3、libbz2.tbd
//4露氮、AudioToolbox
//5祖灰、UIKit
//6、CoreGraphics
//7畔规、AVFoundation
//8局扶、CoreMedia
//9、CoreVideo
//10、MediaPlayer
//11三妈、MobileCoreServices
//12畜埋、OpenGLES
//13、QuartzCore
//14畴蒲、VideoToolbox
按github中的demo使用即可
https://github.com/Bilibili/ijkplayer
問題
遺留問題悠鞍,有高手可以幫忙解決下
1、明明在播放isPlaying()返回false
https://github.com/Bilibili/ijkplayer/issues/1411
可以嘗試在播放器準備播放的回調(diào)中先暫停再播放
@objc private func mediaIsPreparedToPlayDidChange(notification:Notification)
{
JLBLog("準備播放:\(notification)")
player?.pause()
player?.play()
}
2模燥、內(nèi)存泄漏咖祭,至今無解
每次重新播放都會增加1~2M內(nèi)存
https://github.com/Bilibili/ijkplayer/issues/2144
懶人腳本