Cold City Strategy: Listo teaches you to write IOS Streaming Media Player and listoswift in Swift

Source: Internet
Author: User

Cold City Strategy: Listo teaches you to write IOS Streaming Media Player and listoswift in Swift
First, display the player effect:


I still inherit the obsessive-compulsive disorder of Listo myself. I should write a complete strategy from the beginning to the completion to record it, here, I declare that Listo has read a lot of Camp David strategy to share this article with you.

First, Listo uses an open-source third-party framework instead of a system framework. The framework is called the MobileVLCKit framework. As for obtaining the framework, Listo also has the following content, first open the terminal, run the command "$ git clone https://github.com/wuqiong/MobileVLCKit-SDK.git", when this command is completed, in the following command "$ cd MobileVLCKit-SDK", "$. /bootstrap ". Here, Listo must remind later friends that this server is a Japanese server, so the command execution speed is very slow. I hope you will be patient and patient. The preceding operation is shown in the figure below:


At this time, our MobileVLCKit framework has obtained the local machine, and we will open Xcode for use.
First, create an IOS project. Listo will not elaborate here, because it is really basic. After we build a project, we will start to import the third-party framework we downloaded from this project.
Click the project name, find Build Phases on the main interface, and then open Link Binary With Libraries to import the framework (here, Listo is the figure after the import is complete, if the Link Binary With Libraries file is not imported, it should be empty ):

At this time, click the + button in the lower left corner and select the Add Other button to import third-party frameworks Other than the system framework.

Then we enter the stage of searching for the third-party library we downloaded (careful friends will find that Listo does not set the File Download path when executing the Statement on the terminal, which leads to the confusion of searching for the file, fortunately, you can search for the file directory in the upper right corner or publish the file directory in Listo)

In this way, we can select the third row in the rightmost column to import the third-party MobileVLCKit framework.
After the framework is imported, we will perform formal programming. Here, because programming involves the mixing of OC and Swift, Listo writes the annotations in more detail.
First, enter the code in ViewController. swift.


Then, based on the comments of the code, we can easily understand the meaning. At the same time, we need to continue to complete two operations to respond to this code without reporting an error.
First, open the. h file created under Supporting and introduce a third-party framework to import the OC framework:

Next, click storyboard in the file directory and select the video View, modify the view type at the rightmost of the screen (the operation here is to respond to var videoView = self in the program. view // The playback window attribute code of the player instance. I hope you can understand it ):

 
The basic configuration is here. When we run the program again, we will find that there are still many bugs. This is not the reason for the program, but the reason for the configuration, we will find that ios apps require not only a few frameworks, but also sound, subtitles, and other frameworks to work together. Therefore, we need to import the system framework as we just started to import the third-party framework, the Listo list to be imported by the system framework is summarized here.
 
At this time, when we run it again, we will find that the bug is much reduced from 190, but there are still errors. Here is the system compilation C ++ type error. We need to continue to set it, still click the project name, find Build Settings, find Apple LLVM 6.0-Language-C ++, and then set

At this point, we need to think that we are setting C ++ compilation at this time, then we should set the Channel in the project directory. m is set. mm is used to represent the C ++ file, so that all the settings are complete, and then we can Run it to watch the video, if you are not satisfied with the video on the portrait screen, you can set it in General. Here, Listo will not talk much about it.
Conclusion: I think the greatest achievement of this strategy is the idea of mixing OC and Swift. I hope you can come to understand it on your own. Common progress: Open Source China. For details, please declare the source.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.