Flutter Radio Player is the go-to plugin for playing a single streaming URL effortlessly. With support for background music playback right out of the box, it offers seamless integration with platform-native media controls. Whether it's lock screen media controls or deeper integrations like watchOS, CarPlay, WearOS, or Android Auto, Flutter Radio Player handles it all with no extra configuration needed.
flutter pub add flutter_radio_player
import 'package:flutter_radio_player/flutter_radio_player.dart';
final _flutterRadioPlayerPlugin = FlutterRadioPlayer(); // Create an instance of the player
_flutterRadioPlayerPlugin.initialize(
[
{"url": "https://s2-webradio.antenne.de/chillout?icy=https"},
{
"title": "SunFM - Sri Lanka",
"artwork": "images/sample-cover.jpg", // Image needs to be bundled with the app
"url": "https://radio.lotustechnologieslk.net:2020/stream/sunfmgarden?icy=https",
},
{"url": "http://stream.riverradio.com:8000/wcvofm.aac"}
],
true, // Auto play on load
);
Once configured, your player is ready to stream music.
You can control the player using the following methods:
Method | Action |
---|---|
play() |
Plays the audio from the current source |
pause() |
Pauses the audio |
playOrPause() |
Toggles play/pause |
changeVolume() |
Adjusts the volume |
getVolume() |
Retrieves the current volume |
nextSource() |
Skips to the next source in the list (if available) |
previousSource() |
Goes to the previous source |
jumpToSourceIndex() |
Jumps to a specific index in the sources list |
You can also listen to various streams:
Stream | Returns | Description |
---|---|---|
getIsPlayingStream() |
Stream<bool> |
Emits playback status |
getNowPlayingStream() |
Stream<NowPlayingDataChanged> |
Emits metadata such as track name |
getDeviceVolumeChangedStream() |
Stream<double> |
Emits device audio level updates |
To enable background playback, configure background capabilities in Xcode as shown below:
For Android, ensure the following permissions are added to your AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
These permissions are already included in the library.
Check out the Flutter Radio Player Example to see how to implement action methods and streams in your player.
If you find this plugin useful, show your support by:
TNuTkL1ZJGu2xntmtzHzSiH5YdVqUeAujr
Enjoy the plugin!
Sithira ✌️