Broadcast from your Android device. Live Radio is a audio streaming library based on CoolMicApp (default IceCast Android Client), for making the life easier. The detailed explanation is available at my personal blog.
For using the Live Audio library, you need to start a stream server, and then connect your application to the server.
I've used IceCast as the media server on Ubuntu 18.04 LTS. I've added a new stream source to the IceCast config file (/etc/icecast2/icecast.xml
) using these settings:
<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>
The code is published as an AAR library. Therefore, you can add the following dependency to your Android project:
implement 'ir.mstajbakhsh.android:LiveAudio:1.0.0'
Add the following permissions to your Manifest.xml
:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
And check for permission if it is granted to your application or not.
In your Android code (can be either an activity or a service), create a Config
object with the parameters which are set in IceCast stream source and pass it to the Live Audio.
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);
LiveAudio l = new LiveAudio(c);
try {
l.start();
} catch (Exception e) {
e.printStackTrace();
}
The video can be found on YouTube about how to start the stream server and config the Android client. https://youtu.be/ujgRlYc9rMg
You may donate this project using my BitCoin address at:
BitCoin:
1F5uiEmdCLJX5KktWHE1wkc63feKJYMmxS