RadioBrowserWrapper 1.0.0
dotnet add package RadioBrowserWrapper --version 1.0.0
NuGet\Install-Package RadioBrowserWrapper -Version 1.0.0
<PackageReference Include="RadioBrowserWrapper" Version="1.0.0" />
paket add RadioBrowserWrapper --version 1.0.0
#r "nuget: RadioBrowserWrapper, 1.0.0"
// Install RadioBrowserWrapper as a Cake Addin #addin nuget:?package=RadioBrowserWrapper&version=1.0.0 // Install RadioBrowserWrapper as a Cake Tool #tool nuget:?package=RadioBrowserWrapper&version=1.0.0
RadioBrowserWrapper
RadioBrowserWrapper is a lightweight and intuitive .NET wrapper for the Radio Browser API, designed to make it easy for developers to integrate radio station search and stream discovery into their applications.
Whether you're building a media player, an online radio directory, or any project that requires radio station information, this library provides a simple and streamlined interface to interact with the Radio Browser API.
With support for:
- Searching stations by various criteria (country, language, tag, etc.)
- Fetching detailed information about specific stations
- Adding new stations to the Radio Browser database
- Seamlessly integrating live radio streams
RadioBrowserWrapper enables smooth integration of live radio streams into your .NET applications.
Installation
To use RadioBrowserWrapper in your C# project, you need to install the NuGet package. Follow these simple steps:
Using NuGet Package Manager
- Open Your Project: Open your project in Visual Studio or your preferred IDE.
- Open the Package Manager Console: Navigate to
Tools
→NuGet Package Manager
→Package Manager Console
. - Install RadioBrowserWrapper: Type the following command and press Enter:
Install-Package RadioBrowserWrapper
Using .NET CLI
Alternatively, you can use .NET Core CLI to install RadioBrowserWrapper. Open your command prompt or terminal and run:
dotnet add package RadioBrowserWrapper
Verifying the Installation
After installation, make sure that RadioBrowserWrapper is listed in your project dependencies to confirm successful installation.
Usage
To get started with RadioBrowserWrapper
, create an instance of the RadioBrowser
class and use its methods to interact with the Radio Browser API. Below is an example of how you can retrieve various types of data:
using RadioBrowserWrapper;
using RadioBrowserWrapper.Models;
var radioBrowser = new RadioBrowser();
Console.WriteLine("Countries:");
// Get the first 10 countries
var countries = await radioBrowser.GetCountriesAsync(searchOptions: new SimpleSearchOptions
{
Limit = 10
});
foreach (var country in countries)
{
Console.WriteLine($"{country.Name} ({country.ISO_3166_1})");
}
You can retrieve information on codecs used by radio stations:
Console.WriteLine("Codecs:");
// Get codecs
var codecs = await radioBrowser.GetCodecsAsync();
foreach (var codec in codecs)
{
Console.WriteLine($"{codec.Name} ({codec.StationCount})");
}
To get the top 10 stations by votes, use:
Console.WriteLine("Top 10 stations:");
// Get top 10 stations
var topStations = await radioBrowser.GetTopStationsByVotesAsync(10);
foreach (var station in topStations)
{
Console.WriteLine($"{station.Name} ({station.Url})");
}
To retrieve stations from a specific country, for example, Germany:
Console.WriteLine("Stations from Germany:");
// Get first 10 stations from Germany
var gerStations = await radioBrowser.GetStationsByExactCountryAsync("Germany", new ListStationsSearchOptions
{
Limit = 10
});
foreach (var station in gerStations)
{
Console.WriteLine($"{station.Name} ({station.Url})");
}
You can also vote for a station by its UUID:
// Vote for the first station in the top stations list
await radioBrowser.VoteStationAsync(topStations.FirstOrDefault()!.StationUuid);
Dependency Injection and Instancing
There are different ways to create an instance of RadioBrowser
in your project, either by instantiating it directly or using dependency injection (DI) in ASP.NET Core or other DI frameworks.
Instantiating Directly
You can create an instance of RadioBrowser
with default or custom options:
// Default options
var radioBrowser = new RadioBrowser();
// Custom server URL
var radioBrowser = new RadioBrowser(new RadioBrowserOptions
{
ServerUrl = "de1.api.radio-browser.info"
});
Using Dependency Injection (DI)
You can also configure RadioBrowser
to be injected via the service container, making it easier to use in DI-heavy environments like ASP.NET Core:
- With Default Options
var builder = Host.CreateApplicationBuilder();
// Add RadioBrowser to the service collection with default options
builder.Services.AddRadioBrowser();
var serviceProvider = builder.Build().Services;
var radioBrowser = serviceProvider.GetRequiredService<IRadioBrowser>();
- With Custom Options
var builder = Host.CreateApplicationBuilder();
// Add RadioBrowser to the service collection with custom options
builder.Services.AddRadioBrowser(options =>
{
options.ServerUrl = "de1.api.radio-browser.info";
});
var serviceProvider = builder.Build().Services;
var radioBrowser = serviceProvider.GetRequiredService<IRadioBrowser>();
In both cases, you can retrieve an IRadioBrowser
instance from the service provider and use it in your project.
Explore More
The RadioBrowserWrapper
package wraps all available endpoints provided by the Radio Browser API, enabling you to interact with a wide range of functionality. Beyond the examples shown, you can:
- Search stations by tags, language, or bitrate.
- Retrieve stations by name, exact URL, or UUID.
- Get statistics like the number of active stations or the total number of countries.
- Server statistics
- Filter stations based on codec, bitrate, or country.
- and much more
With many customizable search options and methods, there is plenty to explore within the library.
Support the Project
If you find this project useful, consider supporting it by buying me a coffee. Your support is greatly appreciated!
Contributing
Contributions are welcome! If you have a feature to propose or a bug to fix, create a new pull request.
License
This project is licensed under the MIT License.
Acknowledgment
This project is inspired by and built upon the Radio Browser project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Options (>= 6.0.0)
- System.Text.Json (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 111 | 9/21/2024 |