IJKPlayer打包framework(包含https支持)

IJKPlayer只能支持http或者https其中之一,默認(rèn)支持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文件,默認(rèn)不會添加
然后再做framework打包即可

注意:這兩個依賴庫的路徑:ijkplayer-ios/ios/build/universal/lib,只有做了上面openssl相關(guān)的操作,才可以在這個目錄下找到libcrypto.a 和 libssl.a

打包framwork

1、配置Release模式如果下圖

Snip20170601_1.png
Snip20170601_3.png

2、打包真機framework

Snip20170601_5.png

如圖操作,然后編譯即可

3、打包模擬器framework

Snip20170601_6.png

如圖操作,然后編譯即可

4、合并framework

//lipo -create 真機framework路徑 模擬器framework路徑 -output 合并路徑(這里的路徑都需要包含文件名稱)
lipo -create Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework -output IJKMediaFramework

集成framework到項目中

1、導(dǎo)入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
可以嘗試在播放器準(zhǔn)備播放的回調(diào)中先暫停再播放

@objc private func mediaIsPreparedToPlayDidChange(notification:Notification)
 {
    JLBLog("準(zhǔn)備播放:\(notification)")
    player?.pause()
    player?.play()
}

2、內(nèi)存泄漏,至今無解

每次重新播放都會增加1~2M內(nèi)存
https://github.com/Bilibili/ijkplayer/issues/2144

懶人腳本

https://github.com/tiancanfei/IJKPlayer-framework-script

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容