Now the pull stream framework used in the project is ijkPlayer. After the successful integration of ijkPlayer, half of the project of the live broadcast function will be completed. As long as there is a pull stream URL, live broadcast can be played. I have some knowledge about this before, now I will sort out and summarize the related usage (this article focuses on actual combat, and the theory part will not explain). ##### Part 1: Run bilibiliDemo

1. First we went to GitHub to downloadijkplayer. The directory structure is as follows

2. Find our iOS platform, open the project, build, and find the project error.

This error requires downloading FFMPEG because players are based on FFMPEG packages. Solution: CD ijkplayer-master

AllisonMacPro:ijkplayer-master Allison$ ./init-ios.sh

== pull gas-preprocessor base ==
......
== pull ffmpeg base ==
......
== pull ffmpeg fork armv7 ==
......
== pull ffmpeg fork arm64 ==
......
== pull ffmpeg fork i386 ==
......
== pull ffmpeg fork x86_64 ==
Cloning into 'ios/ffmpeg-x86_64'. Compressing objects: 100% (116565/116565), done. Writing objects: 100% (523036/523036), done. Total 523036 (delta 405280), reused 523036 (delta 405280) Switched to a new branch'ijkplayer'
/Users/allison/Desktop/ijkplayer-master

Copy the code

After downloading FFmpeg, run CD ios./compile-ffmpeg.sh clean./compile-ffmpeg.sh all

At this point, we will compile ffmPEG in the iOS directory. This compilation process will be a bit long, because there are many versions to compile, such as real machine, emulator, etc. (1). / the compile – ffmpeg. Sh clean

AllisonMacPro:ios Allison$ ./compile-ffmpeg.sh clean
====================
[*] check xcode version
====================
FF_ALL_ARCHS = armv7 arm64 i386 x86_64
==================
clean ffmpeg-armv7
==================
/Users/allison/Desktop/ijkplayer-master/ios
clean ffmpeg-arm64
==================
/Users/allison/Desktop/ijkplayer-master/ios
clean ffmpeg-i386
==================
/Users/allison/Desktop/ijkplayer-master/ios
clean ffmpeg-x86_64
==================
/Users/allison/Desktop/ijkplayer-master/ios
clean build cache
=================
clean success
Copy the code

(2). / the compile – ffmpeg. Sh all

build_source: /Users/allison/Desktop/ijkplayer-master/ios/ffmpeg-armv7
build_prefix: /Users/allison/Desktop/ijkplayer-master/ios/build/ffmpeg-armv7/output

--------------------
[*] configurate ffmpeg
--------------------

--------------------
[*] check OpenSSL
----------------------

--------------------
[*] configure
----------------------
config:  
......

Copy the code

3. After compiling, run Demo to compare the differences before and after compiling

Note: the demo of the broadcast address may be unavailable, I here just found a live broadcast on the Internet address (blog.csdn.net/chinabinlan…). Replace any of the demo addresses in your project to see the following effect.

The directory structure is as follows:

The running effect is as follows:

Tips: If the following error is displayed:

./libavutil/arm/asm.S:50:9: error: unknown directive
        .arch 
Copy the code

Solution: The latest Xcode has weakened 32-bit support in thecompile-ffmpeg.shRemove thearmv7, modified as follows:FF_ALL_ARCHS_IOS8_SDK="arm64 i386 x86_64"Rerun the command with the error:./compile-ffmpeg.sh allCan.

If armV7 is deleted here, then the Build Settings–Valid Architectures in the project should also be deleted

##### Part 2: Integrating iJkPlayer IJkPlayer is up and running, but how do we integrate demo into our own projects? There are two ways of general integration: the first way: joint compilation project, the second way: iJkPlayer integration. Framework, the framework integration into the project. I’m going to choose the second option here.

1. Open IJKMediaPlayer to generate the Framework

As you can see, this is the framework of a framework.

Let’s change Scheme to Release mode

2. Packaging Framework

In product, we can see that it is red, indicating that the file does not currently exist.

Here we need to produce an emulator version, a real version. (1) We choose a simulator at random

3. Check the framework

4. The merger framework

Actually, what we’re actually merging is not the IJKMediaFrameworkWithSSL bundle, but the IJKMediaFrameworkWithSSL file inside. Consolidated statements

lipo -create "Real version path"Simulator home path -output"Merged path/framework name"
Copy the code

Terminal operations are as follows:

AllisonMacPro:~ Allison$ lipo -create "/Users/allison/Library/Developer/Xcode/DerivedData/IJKMediaPlayer-awlkvnvgkwsadpgacpctqvyymyxn/Build/Products/Release-i phoneos/IJKMediaFrameworkWithSSL.framework/IJKMediaFrameworkWithSSL" "/Users/allison/Library/Developer/Xcode/DerivedData/IJKMediaPlayer-awlkvnvgkwsadpgacpctqvyymyxn/Build/Products/Release-i phonesimulator/IJKMediaFrameworkWithSSL.framework/IJKMediaFrameworkWithSSL" -output "/Users/allison/Library/Developer/Xcode/DerivedData/IJKMediaPlayer-awlkvnvgkwsadpgacpctqvyymyxn/Build/Products/IJKMediaF ramework"
AllisonMacPro:~ Allison$ 
Copy the code

This file is the framework merged with the real machine and emulator. Validation: