I previously created a “HiddenLiveCamera” library for Android. In Github, I’ve received an issue by geminird indicating that phone no responded. I described the reason and geminird asked for live audio stream.
In another post, I’ve wrote about broadcasting media files (such as mp3) using Mixxx and IceCast. In this post, I’ve write about my library and how to use it in Android projects in order to publish stream from Android. The code of the library is grabbed from CoolMic.
The Live Audio Android Library
I’ve created the library from CoolMic code, which is listed as IceCast client library. The code can be found in my GitHub Live Audio Repository. In addition I’ve published it as an AAR library which can be included in your Android applications. Making life easier …
Using The Library
There is needed to configure stream server (here, IceCast) and Android client (using my LiveAudio Android library ). The library code is accessible from my GitHub repository.
IceCast Side
After that, you should config your IceCast (or any other audio stream server on your choice). Using my post about broadcasting yourself, you can start configuration. But for this tutorial, I’ve used following stream source config in my IceCast:
<mount type="normal"> <mount-name>/harleyquinn</mount-name> <username>joker</username> <password>hackme</password> <max-listeners>2</max-listeners> <max-listener-duration>360000</max-listener-duration> <dump-file>/tmp/harley.ogg</dump-file> <charset>ISO8859-1</charset> <public>1</public> <stream-name>Harley Quinn Radio</stream-name> <stream-description>Listen to my live audio from Gotham! With Joker!</stream-description> <genre>Heavy</genre> <bitrate>64</bitrate> <type>application/ogg</type> <subtype>vorbis</subtype> <hidden>1</hidden> <burst-size>65536</burst-size> <mp3-metadata-interval>4096</mp3-metadata-interval> <on-connect>/home/icecast/bin/source-start</on-connect> <on-disconnect>/home/icecast/bin/source-end</on-disconnect> </mount>
Start your IceCast using settings similar to above.
Android Side
The library is published in JCenter, so you can use it in your Android project (I assume that you’re using gradle) like:
implementation 'ir.mstajbakhsh.android:LiveAudio:1.0.0'
After adding the library, one can set a Config object for IceCase configuration, like:
Config c = new Config(); c.host("192.168.43.194"); c.port(8000); c.username("joker"); c.password("hackme"); c.mount("/harleyquinn"); c.sampleRate(16000);
And then pass the config object to a LiveAudio object:
LiveAudio l = new LiveAudio(c);
try {
l.start();
} catch (Exception e) {
e.printStackTrace();
}
Everything is OK. Start your application to broadcast yourself!
Video for Broadcast Yourself Through Android
I’ve created a demo video for using of LiveAudio: