Skip to content

Latest commit

 

History

History
107 lines (81 loc) · 4.14 KB

File metadata and controls

107 lines (81 loc) · 4.14 KB

RadioBrowser4j

Java CI Java Integration Coverage Maven Central ReleaseDate javadoc License Java

A Java API for the RadioBrowser internet radio station online repository.

The library is useful for applications wanting to retrieve internet radio station URLs, streams and meta information.

How to use

A detailed introduction on how to use the library can be found in Radiobrowser4j - A Java API for Internet radio stations.

Maven for JDK targets

First step is to include the dependency in your Maven or Gradle project. For Maven, you need this dependency:

<dependency>
    <groupId>de.sfuhrm</groupId>
    <artifactId>radiobrowser4j</artifactId>
    <version>3.4.0</version>
</dependency>

Use within Android projects

The library works well with Android projects simply by referencing the library within the build.gradle

    implementation 'de.sfuhrm:radiobrowser4j:3.4.0'

If Proguard or R8 code shrinking and obfuscation is being used, then the following entries should be added to the Proguard configuration file (usually proguard-rules.pro):

-dontwarn lombok**
-keep class de.sfuhrm.radiobrowser4j.** { *; }
-keepattributes Signature
-keep class com.google.gson.reflect.TypeToken { *; }
-keep class * extends com.google.gson.reflect.TypeToken

Java use

After adding the dependency, you can start by creating one instance and using it

// discover endpoint
String myAgent = "www.superradioplayer.com";
Optional<String> endpoint = new EndpointDiscovery(myAgent).discover();

// build instance
RadioBrowser radioBrowser = new RadioBrowser(
    ConnectionParams.builder().apiUrl(endpoint.get()).userAgent(myAgent).timeout(5000).build());

// list stations
radioBrowser.listStations(ListParameter.create().order(FieldName.NAME))
    .limit(64)
    .forEach(s -> System.out.printf("%s: %s%n",
        s.getName(),
        s.getUrl()
));

You can take a look at the javadoc documentation to get the full concepts of the API.

More examples

The library was extracted from an internet radio player and recorder program in Java, radiorecorder. You can take a look at real-life usage patterns there.

How it is tested

The API is tested using the WireMock REST testing framework. Mocked web requests/responses are located in the test resources.

License

Copyright 2017-2026 Stephan Fuhrmann

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and