android - how to get channel count of audio file -


i trying retrieve channel count of .wav sound file using trackinfo , mediaformat cant seem handle of mediaformat object believe provide channel count.

i have tried following instruction not helping.

here have far

mediaplayer = new mediaplayer();     mediaplayer.setdatasource(soundpath);     mediaplayer.prepare();      trackinfo info = mediaplayer.gettrackinfo()[0];     mediaformat mf =  

you need use mediaextractor , mediaformat access key_channel_count

here example,

mediaextractor extractor = new mediaextractor(); extractor.setdatasource(path); //where path string variable , points data source mediaformat format = extractor.gettrackformat(i); //where int variable , denotes index value of track. //for first track: = 0;  int count = format.getinteger(mediaformat.key_channel_count); 

i recommend reading example in mediaextractor class description android developer reference. here link:

http://developer.android.com/reference/android/media/mediaextractor.html

i hope helps. happy coding.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -