Skip to content

Commit 07281b6

Browse files
committed
Update to audioplayers v4
1 parent 4e9b44b commit 07281b6

File tree

5 files changed

+404
-121
lines changed

5 files changed

+404
-121
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ If you encounter issues running flutter-pi on any of the supported platforms lis
4242
2.2 [Building the App](#building-the-app-new-method-linux-only)
4343
2.3 [Running your App with flutter-pi](#running-your-app-with-flutter-pi)
4444
2.4 [gstreamer video player](#gstreamer-video-player)
45+
2.5 [audioplayers](#audioplayers)
4546
3. **[Performance](#-performance)**
4647
3.1 [Graphics Performance](#graphics-performance)
4748
3.2 [Touchscreen latency](#touchscreen-latency)
@@ -414,6 +415,18 @@ To use the gstreamer video player, just rebuild flutter-pi (delete your build fo
414415
415416
And then, just use the stuff in the official [video_player](https://pub.dev/packages/video_player) package. (`VideoPlayer`, `VideoPlayerController`, etc, there's nothing specific you need to do on the dart-side)
416417
418+
### audioplayers
419+
As of current moment flutter-pi implements plugin for `audioplayers: ^4.0.0`.
420+
There are several things you need to keep in mind:
421+
- As flutter-pi is intended for use on constrained systems like raspberry pi, you should avoid creating multiple temporary instances and instead prefer to use one global instance of `AudioPlayer`. There is limit you can easily hit if you're going to spam multiple instances of `AudioPlayer`
422+
- Plugin was tested to work with ALSA and `pulseaudio` might prevent the plugin from playing audio correctly:
423+
- Hence please make sure you delete `pulseaudio` package from your system.
424+
- Make sure you have `gstreamer1.0-alsa` package installed in addition to packages needed for gstreamer video player.
425+
- Make sure you can list audio devices using command: `aplay -L`
426+
- If there is error, please investigate why and fix it before using audio
427+
- One of the common reasons is outdated ALSA config in which case you should delete existing config and replace it with up to date one
428+
- Finally, if you want to verify your audio setup is good, you can use `gst-launch` command to invoke `playbin` on audio file directly.
429+
417430
## 📊 Performance
418431
### Graphics Performance
419432
Graphics performance is actually pretty good. With most of the apps inside the `flutter SDK -> examples -> catalog` directory I get smooth 50-60fps on the Pi 4 2GB and Pi 3 A+.

src/plugins/audioplayers.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,21 @@ void audio_player_set_volume(struct audio_player *self, double volume);
3030

3131
void audio_player_set_playback_rate(struct audio_player *self, double rate);
3232

33+
void audio_player_set_balance(struct audio_player *self, double balance);
34+
3335
void audio_player_set_position(struct audio_player *self, int64_t position);
3436

3537
void audio_player_set_source_url(struct audio_player *self, char *url);
3638

3739
bool audio_player_is_id(struct audio_player *self, char *id);
3840

41+
const char* audio_player_subscribe_channel_name(const struct audio_player *self);
42+
43+
///Asks to subscribe to channel events
44+
///
45+
///`value` - Indicates whether to subscribe or unsubscribe
46+
///
47+
///Returns `true` if player uses `channel`, otherwise returns `false
48+
bool audio_player_set_subscription_status(struct audio_player *self, const char *channel, bool value);
49+
3950
#endif // AUDIOPLAYERS_H_

src/plugins/audioplayers/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## audioplayers plugin
2+
3+
### Requirements
4+
5+
- `audioplayers` version `^4.0.0`
6+
- Working gstreamer installation, including corresponding audio plugin (e.g. `gstreamer1.0-alsa`)
7+
8+
### Troubleshooting
9+
10+
- Check that you can list ALSA devices via command `aplay -L`;
11+
- Check that you can launch `playbin` on any audio file via `gst-launch`;
12+
- Make sure `pulseaudio` is deleted
13+
14+
### pulseaudio
15+
16+
Please note that plugin was not tested with `pulseaudio` and it is up to you to make gstreamer work via it.
17+
As `pulseaudio` takes full control over audio devices, `ALSA` will no longer function correctly with `pulseaudio` installed

0 commit comments

Comments
 (0)