Skip to content

Update to audioplayers v5 #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -417,6 +418,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: ^5.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
13 changes: 13 additions & 0 deletions src/plugins/audioplayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@ 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);

void audio_player_release(struct audio_player *self);

#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