Android solves the problem that the network audio buffer of mediaplayer is too slow.

Source: Internet
Author: User

I believe many people use mediaplayer to play Network Audio. The buffer between prepare and prepareasync is too slow. How can this problem be solved? Now we will provide a solution for hands-on testing and using it in actual projects.
In this solution, the Framework vitamio (http://vitamio.org/) is used, the download page has a more detailed download project and introduction. Mainly Demo: https://github.com/yixia/VitamioDemo and dependency Library: https://github.com/yixia/VitamioBundle/tree/v3.0

However, if you only use the dependent library instead of your own re-compiled FFMPEG, the dynamic library so under the RES is 5 MB large, which will cause the APK to be too large. The following are the steps and notes for compiling FFMPEG by yourself. This is officially provided: How to Use the compiled ffmpeghttp: // vitamio.org/pages/how-to-use-vitamio-with-your-own-ffmpeg-build in vitamio? Locale = ZH-CN

I compiled it on a Mac system, and other systems are similar. I mainly pay attention to my environment, for example, GCC for Mac and cygwin for Windows.
1. Make sure that the GCC compiling environment has been installed on your Mac. If not, download it from xcode.
2. Download ndk, vitamio recommended we are using the ndk-r8b version
3. Enter export android_ndk =/path/to/Your/Android-ndk in the terminal (export is a keyword; android_ndk is followed by the ndk address you decompress)

4. Locate the contents of the folder downloaded on the terminal at http://github.com/yixia/ffmpeg-androidnet, and then execute the./FFmpeg-Android.sh command.
4.1 run git clone git: // source.ffmpeg.org/ffmpeg.git FFMPEG to download the FFMPEG code before using the configure -- Help Command.

5. Supplement 4. According to the official explanation, we canFFmpeg-Android.shMake appropriate changes. We mainly focus onThe configuration under ffmpeg_flags.
If you need to configure multiple, you can separate them with commas (,).
-- Enable-decoder = AAC, MP3, MPEG4 \ practice, write OK
5.1 attach an ffmpeg_flags configuration example:

FFMPEG_FLAGS="--target-os=linux \  --arch=arm \  --enable-cross-compile \  --cross-prefix=arm-linux-androideabi- \  --enable-shared \  --disable-symver \  --disable-doc \  --disable-ffplay \  --disable-ffmpeg \  --disable-ffprobe \  --disable-ffserver \  --disable-avdevice \  --disable-avfilter \  --disable-encoders \  --disable-muxers \  --disable-filters \  --disable-devices \  --disable-everything \  --enable-protocol=http,md5,https,cache,file,httpproxy  \  --enable-parser=aac,aac_latm,mpegaudio \  --enable-demuxer=aac,ogg \  --enable-decoder=aac_latm,aac \  --enable-bsf=aac_adtstoasc,noise \  --enable-network \  --enable-swscale  \  --enable-asm \  --enable-version3"

 

6. execution is a long wait, but do not relax. You may encounter errors similar to ccache. This error will cause an error that cannot generate the libffmpeg. So file.

6.1 solution: Go to the online http://mxcl.github.com/homebrew/ to copy the address similar to the following to the terminal, press enter to execute
     6.2 ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
   
6.3 
After the installation is complete, run brew install ccache.
6.4 re-compile and execute the sh file.
7. The official documentation also mentions that the Res/raw/libarm. So file in vitamiobundle is a 7-zip compressed file. After obtaining this information, we can use the brew search 7zip command in the terminal to search for the required software. After finding this information, we can use brew install x as the name of the software you need.
Then according to the 7z -- Help Command to obtain the command to decompress the so file, replace libffmpeg. So with the decompressed libffmpeg. So, the official website http://vitamio.org/pages/how-to-use-vitamio-with-your-own-ffmpeg-build? Locale = ZH-CN is prompted. After replacement, use the command to package it back to the so file.
8. Overwrite this self-compiled file to the res/raw/libarm. So file. At this point, all operations have been completed. Later, I will complete this document and attach some images.
9. Attach the command for extracting p7zip:
9.1 pz x files to be decompressed-O specifies the directory to be decompressed, for example:7z x/users/ARI/downloads/VitamioBundle-3.0/RES/raw/libarm. So-O/users/ARI/downloads/VitamioBundle-3.0/RES/raw/lib

    9.2 pz a specifies the files or directories to be compressed to. Multiple files or directories are separated by spaces. For example:7z A/users/ARI/downloads/VitamioBundle-3.0/RES/raw/libarm. So 60 61 70 71

 

 

 

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.