Skip to content

Commit

Permalink
Update to audioplayers v4
Browse files Browse the repository at this point in the history
  • Loading branch information
DoumanAsh committed Sep 22, 2023
1 parent 4e9b44b commit 07281b6
Show file tree
Hide file tree
Showing 5 changed files with 404 additions and 121 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ If you encounter issues running flutter-pi on any of the supported platforms lis
2.2 [Building the App](#building-the-app-new-method-linux-only)
2.3 [Running your App with flutter-pi](#running-your-app-with-flutter-pi)
2.4 [gstreamer video player](#gstreamer-video-player)
2.5 [audioplayers](#audioplayers)
3. **[Performance](#-performance)**
3.1 [Graphics Performance](#graphics-performance)
3.2 [Touchscreen latency](#touchscreen-latency)
Expand Down Expand Up @@ -414,6 +415,18 @@ To use the gstreamer video player, just rebuild flutter-pi (delete your build fo
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)
### audioplayers
As of current moment flutter-pi implements plugin for `audioplayers: ^4.0.0`.
There are several things you need to keep in mind:
- 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`
- Plugin was tested to work with ALSA and `pulseaudio` might prevent the plugin from playing audio correctly:
- Hence please make sure you delete `pulseaudio` package from your system.
- Make sure you have `gstreamer1.0-alsa` package installed in addition to packages needed for gstreamer video player.
- Make sure you can list audio devices using command: `aplay -L`
- If there is error, please investigate why and fix it before using audio
- 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
- Finally, if you want to verify your audio setup is good, you can use `gst-launch` command to invoke `playbin` on audio file directly.
## 📊 Performance
### Graphics Performance
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+.
Expand Down
11 changes: 11 additions & 0 deletions src/plugins/audioplayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ void audio_player_set_volume(struct audio_player *self, double volume);

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

void audio_player_set_balance(struct audio_player *self, double balance);

void audio_player_set_position(struct audio_player *self, int64_t position);

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

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

const char* audio_player_subscribe_channel_name(const struct audio_player *self);

///Asks to subscribe to channel events
///
///`value` - Indicates whether to subscribe or unsubscribe
///
///Returns `true` if player uses `channel`, otherwise returns `false
bool audio_player_set_subscription_status(struct audio_player *self, const char *channel, bool value);

#endif // AUDIOPLAYERS_H_
17 changes: 17 additions & 0 deletions src/plugins/audioplayers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## audioplayers plugin

### Requirements

- `audioplayers` version `^4.0.0`
- Working gstreamer installation, including corresponding audio plugin (e.g. `gstreamer1.0-alsa`)

### Troubleshooting

- Check that you can list ALSA devices via command `aplay -L`;
- Check that you can launch `playbin` on any audio file via `gst-launch`;
- Make sure `pulseaudio` is deleted

### pulseaudio

Please note that plugin was not tested with `pulseaudio` and it is up to you to make gstreamer work via it.
As `pulseaudio` takes full control over audio devices, `ALSA` will no longer function correctly with `pulseaudio` installed
Loading

0 comments on commit 07281b6

Please sign in to comment.