Skip to content

Commit 692cec2

Browse files
authored
Update to audioplayers v5 (#345)
* Update to audioplayers v5 * Update audioplayers impl: Emit error if set source fails to set ready state Implement new release method Return NULL in align with audioplayers API Fix playbin identification in on media state change * Update note on supported version of audioplayers
1 parent b816d8c commit 692cec2

File tree

5 files changed

+432
-128
lines changed

5 files changed

+432
-128
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)
@@ -417,6 +418,18 @@ To use the gstreamer video player, just rebuild flutter-pi (delete your build fo
417418
418419
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)
419420
421+
### audioplayers
422+
As of current moment flutter-pi implements plugin for `audioplayers: ^5.0.0`.
423+
There are several things you need to keep in mind:
424+
- 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`
425+
- Plugin was tested to work with ALSA and `pulseaudio` might prevent the plugin from playing audio correctly:
426+
- Hence please make sure you delete `pulseaudio` package from your system.
427+
- Make sure you have `gstreamer1.0-alsa` package installed in addition to packages needed for gstreamer video player.
428+
- Make sure you can list audio devices using command: `aplay -L`
429+
- If there is error, please investigate why and fix it before using audio
430+
- 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
431+
- Finally, if you want to verify your audio setup is good, you can use `gst-launch` command to invoke `playbin` on audio file directly.
432+
420433
## 📊 Performance
421434
### Graphics Performance
422435
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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,23 @@ 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+
50+
void audio_player_release(struct audio_player *self);
51+
3952
#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)