VLC-based Android multimedia solution, vlcandroid
Some time ago, the project needed to play videos, streaming media, and view and monitor in Android, and then studied the Android multimedia solution.
After searching, there are roughly the following types:
Android MediaPlayer is a built-in player for Android. It supports a limited number of formats: 3gp mp4 and does not support streaming media.
FFmpeg is a powerful cross-platform multimedia solution that requires NDK compilation and supports massive formats and streaming media.
Google ExoPlayer is a pre-built player launched by Google in 2014 between the existing MediaPlayer and the custom media player. It requires Android 4.1 +, supports multiple formats, DASH (Dynamic Adaptive Streaming over HTTP), and is easy to scale.
Vitamio is a popular third-party multi-media library developed by Chinese people. It supports Android and iOS. authorization is required for commercial use of the latest version.
VLC is another powerful cross-platform multimedia solution that supports massive formats and streaming media. It integrates some FFmpeg functions and officially supports the Android platform.
This article uses VLC to play a video on Android. The final effect is as follows:
1. Compile VLC Android
VLC official git Repository: http://git.videolan.org/
VLC Android official git Repository: https://code.videolan.org/videolan/vlc-android
VLC Android official compilation instructions: https://wiki.videolan.org/AndroidCompile
VLC Android provides Android native aar packages, which can be directly referenced in projects. According to the preceding instructions, you can compile the aar packages of the corresponding architecture (such as ARM, x86, and MIPS.
I have compiled a ARMv7 aar package, which can be downloaded here.
Project source code is hosted on Github: https://github.com/mymbrooks/VLCAndroidDemo
2. Create an Android project and copy the aar package to the app/libs directory:
3. Modify app/build. gradle and add:
4. Create the first interface to support local and remote video playback:
5. To be compatible with Android 6.0 +, you must first request the permission to read the SD card when playing a local video:
6. A third-party method is used to conveniently obtain the real video paths of Android 4.4 and later versions:
7. Create a VLC player interface and use SurfaceView to display the video. progress bar and volume control are supported. Pause and continue. Full Screen Display is supported:
8. Playback progress control:
9. Get video length and other information:
10. Update time progress during playback:
11. format the playback time progress to hh: mm: ss.
12. The method used for playing local and remote videos is different:
VLC Android provides many functions. For more advanced functions, see the official App source code.
In addition, VLC Android also provides a native control, which can be used on your own: