Giter Site home page Giter Site logo

radiobrowser-android's Introduction

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

radiobrowser-android's People

Contributors

r-cohen avatar raphael-dario avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.