GSYVideoPlayer's Github page is /CarGuo/GSYVideoPlayer, as of August 18, 2024, the project has 20,000 Github stars and 0.42 million copies, which is quite good, knowing that the FFmpeg project only has 44,400 stars on Github in the same period. This is quite a good result.
However, if you integrate GSYVideoPlayer in your app project, you should pay attention to the environment configuration to avoid import failure. The specific import procedure is described below:
I. Installing Android Studio Jellyfish
Although the homepage of GSYVideoPlayer does not specify in which version of Android Studio to import the library, but in practice, we found that even the Android Studio Dolphin (small dolphin version) launched two years ago can not import GSYVideoPlayer properly, let alone the earlier Android Studio, let alone earlier versions of Android Studio.
If you want to import and call GSYVideoPlayer successfully, you need to install a newer version of Android Studio, such as the Jellyfish version of Android Studio Jellyfish. although the Jellyfish version of the new app project is encoded in Kotlin, GSYVideoPlayer supports Java encoding, so you can still call GSYVideoPlayer in Java code. So you can still call GSYVideoPlayer in Java code.
Second, modify the configuration of the App project
First open the App project's and add the following two lines of repository configuration inside the repositories node in order to pull the GSYVideoPlayer library from the specified repository.
Next, open the App module's and internally add the following configuration inside the dependencies node to indicate the introduction of version 9.0.0 of the GSYVideoPlayer library.
Then open the App module's and add the following internet permission configuration:
After completing the above three configuration changes, you can only use GSYVideoPlayer's player control in the app code.
Third, the use of the player in the App code
GSYVideoPlayer provides three kinds of player controls, namely NormalGSYVideoPlayer, GSYADVideoPlayer and ListGSYVideoPlayer, and their usage in the app code are described below:
1、Ordinary Player NormalGSYVideoPlayer
NormalGSYVideoPlayer is used to play a single video file. The code for placing this control in an XML file is shown below:
2. Advertisement Player GSYADVideoPlayer
GSYADVideoPlayer is used to play advertisements in the opening credits of a video file. Note that this control should be used in conjunction with NormalGSYVideoPlayer. The code for placing the control in the XML file is shown below:
3、ListGSYVideoPlayer
ListGSYVideoPlayer is used to play a number of video files in a chronological list. The code for placing this control in an XML file is shown below:
After placing any one of the above three player controls in the XML file, then go back to the Java code to perform the video playback operation. Taking NormalGSYVideoPlayer as an example, the code example for playing a single video file through Java is as follows:
Then run the test app and observe the effect of NormalGSYVideoPlayer playing network video as shown below:
Because NormalGSYVideoPlayer's playback kernel is based on IJKPlayer, EXOPlayer and AliPlayer, which support HLS, RTMP and other live links by default, there is no need to change the code, just change the video address to HLS link ending with m3u8 or RTMP link starting with rtmp, then you can let the NormalGSYVideoPlayer to play live content. The effect of using NormalGSYVideoPlayer to play live video is shown below:
For more details on FFmpeg development see