An Android library for consuming RadioBrowser API
Add the Jitpack maven repository in the list of repositories.
repositories {
...
maven { url 'https://jitpack.io' }
}
Add the dependeny declaration to your app or module's build.gradle
file.
dependencies {
implementation 'com.github.r-cohen:RadioBrowser-Android:1.0.8'
}
Instantiate the RadioBrowserApi:
val api = RadioBrowserApi()
You can optionally set the User-Agent of your app in the RadioBrowserApi constructor.
If you don't set any User-Agent, the app will use the default one: RC.RadioBrowserAndroid
val api = RadioBrowserApi("MyRadioApp")
api.getCountries(
onSuccess = { countries ->
countries.forEach { country -> outputText("country: $country") }
},
onFail = { error -> outputText("error: $error") }
)
api.getStationsByCountry(
countryCode = "IL",
offset = 0,
limit = 500,
onSuccess = { stations ->
stations.forEach { station -> outputText("station $station") }
},
onFail = { error -> outputText("error: $error") }
)
api.searchStationsByName(
search = "kol chai",
offset = 0,
limit = 500,
onSuccess = { stations ->
stations.forEach { station -> outputText("station $station") }
},
onFail = { error -> outputText("error: $error") }
)
getStatesByCountry
getStationsByState
When a user starts streaming a radio, it is good practice to call the stationClick
API method in order to update the station's statistics.
api.stationClick(
stationUuid = stationUuid,
onSuccess = { clickResult ->
outputText("$clickResult")
},
onFail = { error -> outputText("error: $error") }
)