Skip to content

Latest commit

 

History

History
83 lines (75 loc) · 1.96 KB

README.md

File metadata and controls

83 lines (75 loc) · 1.96 KB

RadioBrowser-Android

An Android library for consuming RadioBrowser API

Install

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'
}

Usage

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")

Get list of countries

api.getCountries(
    onSuccess = { countries ->
        countries.forEach { country -> outputText("country: $country") }
    },
    onFail = { error -> outputText("error: $error") }
)

Get list of stations by country

api.getStationsByCountry(
    countryCode = "IL",
    offset = 0,
    limit = 500,
    onSuccess = { stations ->
        stations.forEach { station -> outputText("station $station") }
    },
    onFail = { error -> outputText("error: $error") }
)

Search a station by name

api.searchStationsByName(
    search = "kol chai",
    offset = 0,
    limit = 500,
    onSuccess = { stations ->
        stations.forEach { station -> outputText("station $station") }
    },
    onFail = { error -> outputText("error: $error") }
)

Other usefull api methods

getStatesByCountry
getStationsByState

User station click

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") }
)