關於ijkplayer的編譯、打包framework和https支持 推薦你們看hext123的這篇文章ijkplayer 的編譯、打包 framework 和 https 支持 還有iOS_小剛哥的這篇iOS直播之ijkplayer的集成與簡單使用(播放)。這篇文章更爲詳細,雖然正常狀況下開發者的環境配置對於ijkplayer來講應該只差一個brew install yasm
,可是萬一有須要這也是很好的指導。html
執行這一步時報錯,以下。git
./compile-ffmpeg.sh all
複製代碼
AS libavcodec/arm/aacpsdsp_neon.o
./libavutil/arm/asm.S:50:9: error: unknown directive
.arch armv7-a
^
make: *** [libavcodec/arm/aacpsdsp_neon.o] Error 1
make: *** Waiting for unfinished jobs....
複製代碼
須要在 compile-ffmpeg.sh
刪除 armv7 , 修改方法以下: github
也就是將swift
FF_ALL_ARCHS_IOS8_SDK="armv7 arm64 i386 x86_64"
複製代碼
改成bash
FF_ALL_ARCHS_IOS8_SDK="arm64 i386 x86_64"
複製代碼
我這裏有測試過是否須要刪除全部的armv7,我只刪除了上圖那一行的armv7,編譯經過。因此應該是不須要的。app
接着從新執行編譯ffmpeg的命令:框架
./compile-ffmpeg.sh all
複製代碼
####編譯報錯問題 須要註釋兩個文件的引用代碼。兩個文件分別是avconfig.h
和config.h
若是點擊報錯的地方沒反應,全局搜索也找不到,那麼你就須要直接到文件目錄去找了 ide
反鍵選擇Reveal in Log
,根據路徑找到avconfig.h
測試
# include "armv7/avconfig.h"
config.h
也是同理 flex
# include "armv7/config.h"
打包完Framework並添加到工程後,須要測試框架是否正常
Xcode 10.1 swift 4.2
視頻源直接上網搜索就好,這是個我搜索出來的網址
//
// PlayerViewController.swift
// ProjectFramework
//
// Created by Bart Simpson on 2018/11/16.
// Copyright © 2018年 simpsons. All rights reserved.
//
import UIKit
import IJKMediaFramework
class PlayerViewController: UIViewController {
var player:IJKFFMoviePlayerController!
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.white
showVideo()
// Do any additional setup after loading the view.
}
func showVideo(){
let options = IJKFFOptions.byDefault()
//視頻源地址
let url = URL.init(string: "http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8")
//初始化播放器,播放在線視頻或直播(RTMP)
player = IJKFFMoviePlayerController.init(contentURL: url, with: options)
//播放頁面視圖寬高自適應
let autoresize = UIView.AutoresizingMask.flexibleWidth.rawValue |
UIView.AutoresizingMask.flexibleHeight.rawValue
player.view.autoresizingMask = UIView.AutoresizingMask(rawValue: autoresize)
player.view.frame = self.view.bounds
player.scalingMode = .aspectFit //縮放模式
player.shouldAutoplay = true //開啓自動播放
self.view.autoresizesSubviews = true
self.view.addSubview(player.view)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//開始播放
self.player.prepareToPlay()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//關閉播放器
self.player.shutdown()
}
}
複製代碼