|
1 | 1 |  |
2 | 2 |
|
3 | | -# flutter_radio_player |
| 3 | +# Flutter Radio Player |
4 | 4 |
|
5 | 5 |  |
6 | 6 |  |
7 | 7 |  |
8 | 8 |  |
9 | 9 |
|
10 | | -The only player if you need to play one streaming URL at a time. Flutter Radio Player supports playing a single source |
11 | | -precisely. By default, plugin supports background music playing by default. No additional configurations needed. |
12 | | -Flutter radio player effortlessly integrates with platform native media controls enabling lock screen controling |
13 | | -of the playing media as well <strong>integrates with iOS watchOS, CarPlay and Android's WearOS, Android Auto without any |
14 | | -configuration </strong> |
15 | | -all with the help of Flutter Radio Player's native platform integrations. |
| 10 | +**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. |
16 | 11 |
|
17 | 12 | ## Features |
18 | 13 |
|
19 | | -* Supports background playing with zero configurations out of the box |
20 | | -* Integrates with platform native watch interfaces like WatchOs and WearOs |
21 | | -* Integrates well with platform native AutoMotive infotainment system such as Apple CarPlay and Android Auto |
22 | | -* Reactive by default |
23 | | -* Extracts Icy / Meta data from streams (if available) |
| 14 | +- **Background Playback**: Plays audio in the background without any configuration. |
| 15 | +- **Watch Integration**: Seamlessly integrates with WatchOS and WearOS for native watch control. |
| 16 | +- **Automotive Systems**: Supports infotainment systems like Apple CarPlay and Android Auto. |
| 17 | +- **Reactive by Default**: Automatically reacts to stream changes. |
| 18 | +- **ICY/Metadata Extraction**: Extracts stream metadata if available. |
24 | 19 |
|
25 | | -### Getting Started with Flutter Radio Player |
| 20 | +## Getting Started |
26 | 21 |
|
27 | | -1. Install the player |
| 22 | +### 1. Install the Player |
28 | 23 |
|
29 | 24 | ```bash |
30 | 25 | flutter pub add flutter_radio_player |
31 | 26 | ``` |
32 | 27 |
|
33 | | -2. Import the library |
| 28 | +### 2. Import the Library |
34 | 29 |
|
35 | 30 | ```dart |
36 | 31 | import 'package:flutter_radio_player/flutter_radio_player.dart'; |
37 | 32 | ``` |
38 | 33 |
|
39 | | -3. Configuring the player |
| 34 | +### 3. Configure the Player |
40 | 35 |
|
| 36 | +```dart |
| 37 | +final _flutterRadioPlayerPlugin = FlutterRadioPlayer(); // Create an instance of the player |
| 38 | +_flutterRadioPlayerPlugin.initialize( |
| 39 | + [ |
| 40 | + {"url": "https://s2-webradio.antenne.de/chillout?icy=https"}, |
| 41 | + { |
| 42 | + "title": "SunFM - Sri Lanka", |
| 43 | + "artwork": "images/sample-cover.jpg", // Image needs to be bundled with the app |
| 44 | + "url": "https://radio.lotustechnologieslk.net:2020/stream/sunfmgarden?icy=https", |
| 45 | + }, |
| 46 | + {"url": "http://stream.riverradio.com:8000/wcvofm.aac"} |
| 47 | + ], |
| 48 | + true, // Auto play on load |
| 49 | +); |
41 | 50 | ``` |
42 | | - final _flutterRadioPlayerPlugin = FlutterRadioPlayer(); // create an instance of the player |
43 | | - _flutterRadioPlayerPlugin.initialize( |
44 | | - [ |
45 | | - { |
46 | | - "url": "https://s2-webradio.antenne.de/chillout?icy=https", |
47 | | - }, |
48 | | - { |
49 | | - "title": "SunFM - Sri Lanka", |
50 | | - "artwork": "images/sample-cover.jpg", // needs be bundled with the app |
51 | | - "url": |
52 | | - "https://radio.lotustechnologieslk.net:2020/stream/sunfmgarden?icy=https", |
53 | | - }, |
54 | | - { |
55 | | - "url": "http://stream.riverradio.com:8000/wcvofm.aac" |
56 | | - } |
57 | | - ], |
58 | | - true, // auto play on load |
59 | | - ); |
60 | | -``` |
61 | 51 |
|
62 | | -once you have the basic player setup you are ready to stream music |
| 52 | +Once configured, your player is ready to stream music. |
| 53 | + |
| 54 | +### Manipulating the Player |
63 | 55 |
|
64 | | -### Manipulating the player |
| 56 | +You can control the player using the following methods: |
65 | 57 |
|
66 | | -To manipulate the player, you have below methods available |
| 58 | +| Method | Action | |
| 59 | +|------------------------|------------------------------------------------------------| |
| 60 | +| `play()` | Plays the audio from the current source | |
| 61 | +| `pause()` | Pauses the audio | |
| 62 | +| `playOrPause()` | Toggles play/pause | |
| 63 | +| `changeVolume()` | Adjusts the volume | |
| 64 | +| `getVolume()` | Retrieves the current volume | |
| 65 | +| `nextSource()` | Skips to the next source in the list (if available) | |
| 66 | +| `previousSource()` | Goes to the previous source | |
| 67 | +| `jumpToSourceIndex()` | Jumps to a specific index in the sources list | |
67 | 68 |
|
68 | | -#### Available methods list |
| 69 | +### Available Streams |
69 | 70 |
|
70 | | -| Method | Action | |
71 | | -|------------------------|-------------------------------------------------------------| |
72 | | -| play() | Plays the audio item in the queue | |
73 | | -| pause() | Pauses the audio | |
74 | | -| playOrPause() | Toggle the player playback | |
75 | | -| changeVolume() | Change the volume in the player instance | |
76 | | -| getVolume() | Get the current volume | |
77 | | -| nextSource() | Advance to the next audio source in the list (if available) | |
78 | | -| previousSource() | Previous audio source | |
79 | | -| jumpToSourceIndex(int) | Jumps to the provided index from the sources array | |
| 71 | +You can also listen to various streams: |
80 | 72 |
|
81 | | -#### Available streams list |
| 73 | +| Stream | Returns | Description | |
| 74 | +|-----------------------------------|-------------------------------------|------------------------------------------------------| |
| 75 | +| `getIsPlayingStream()` | `Stream<bool>` | Emits playback status | |
| 76 | +| `getNowPlayingStream()` | `Stream<NowPlayingDataChanged>` | Emits metadata such as track name | |
| 77 | +| `getDeviceVolumeChangedStream()` | `Stream<double>` | Emits device audio level updates | |
82 | 78 |
|
83 | | -| Method | Returns | Action | |
84 | | -|--------------------------------|-------------------------------------|------------------------------------------------------| |
85 | | -| getIsPlayingStream() | stream of boolean | Returns the playback status as stream | |
86 | | -| getNowPlayingStream() | stream NowPlayingDataChanged Object | Return the now playing source ICY or Meta track name | |
87 | | -| getDeviceVolumeChangedStream() | stream of float | Device audio level stepper values | |
| 79 | +## Platform Configuration |
88 | 80 |
|
89 | | -### Platform Configurations |
| 81 | +### iOS |
90 | 82 |
|
91 | | -- iOS |
92 | | - For iOS, You have to enable background capabilities like shown in the below image |
93 | | -  |
| 83 | +To enable background playback, configure background capabilities in Xcode as shown below: |
94 | 84 |
|
| 85 | + |
95 | 86 |
|
96 | | -- Android |
97 | | - For newer android, add below permissions to play audio in background in `AndroidManifest.xml`. This is already added |
98 | | - to library |
99 | | - ```xml |
100 | | - <uses-permission android:name="android.permission.INTERNET" /> |
101 | | - <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> |
102 | | - <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> |
103 | | - ``` |
| 87 | +### Android |
| 88 | + |
| 89 | +For Android, ensure the following permissions are added to your `AndroidManifest.xml`: |
| 90 | + |
| 91 | +```xml |
| 92 | +<uses-permission android:name="android.permission.INTERNET" /> |
| 93 | +<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> |
| 94 | +<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" /> |
| 95 | +``` |
104 | 96 |
|
105 | | -**Be sure to check out the [Flutter Radio Player Example](/example) to get an idea of how to use action methods and |
106 | | -streams to create a simple yet powerful player** |
| 97 | +> These permissions are already included in the library. |
107 | 98 |
|
108 | | -## Support this plugin |
| 99 | +**Check out the [Flutter Radio Player Example](/example)** to see how to implement action methods and streams in your player. |
109 | 100 |
|
110 | | -Please hit a like to plugin on pub if you used it and love it. put a ⭐️ my |
111 | | -GitHub [repo](https://github.com/Sithira/FlutterRadioPlayer) and show me some ♥️ so i can keep working on this. |
| 101 | +## Support the Plugin |
112 | 102 |
|
113 | | -and last but not least, ONLY if you think this was worth it and saved you time here is my USDT-TR20 address so you can |
114 | | -buy me a coffee ☕️ |
| 103 | +If you find this plugin useful, show your support by: |
115 | 104 |
|
116 | | -`` |
117 | | -TNuTkL1ZJGu2xntmtzHzSiH5YdVqUeAujr |
118 | | -`` |
| 105 | +- Giving it a ⭐️ on [GitHub](https://github.com/Sithira/FlutterRadioPlayer) |
| 106 | +- Leaving a like on Pub |
| 107 | +- Showing some ♥️ and buying me a coffee via USDT-TR20 at this address: `TNuTkL1ZJGu2xntmtzHzSiH5YdVqUeAujr` |
119 | 108 |
|
120 | | -**ENJOY THE PLUGIN** <br /> |
121 | | -Sithira ✌️ |
| 109 | +**Enjoy the plugin!** |
| 110 | +Sithira ✌️ |
0 commit comments