- Notifications
You must be signed in to change notification settings - Fork66
Flutter Radio Player, A Plugin to handle streaming audio without a hassle
License
Sithira/FlutterRadioPlayer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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.
- Background Playback: Plays audio in the background without any configuration.
- Watch Integration: Seamlessly integrates with WatchOS and WearOS for native watch control.
- Automotive Systems: Supports infotainment systems like Apple CarPlay and Android Auto.
- Reactive by Default: Automatically reacts to stream changes.
- ICY/Metadata Extraction: Extracts stream metadata if available.
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 yourAndroidManifest.xml
:
<uses-permissionandroid:name="android.permission.INTERNET" /><uses-permissionandroid:name="android.permission.FOREGROUND_SERVICE" /><uses-permissionandroid:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
These permissions are already included in the library.
Check out theFlutter 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:
- Giving it a ⭐️ onGitHub
- Leaving a like on Pub
- Showing some
♥️ and buying me a coffee via USDT-TR20 at this address:TNuTkL1ZJGu2xntmtzHzSiH5YdVqUeAujr
Enjoy the plugin!
Sithira ✌️
About
Flutter Radio Player, A Plugin to handle streaming audio without a hassle