Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow playing of live streamed data #1806

Open
1 task done
Binozo opened this issue May 26, 2024 · 1 comment
Open
1 task done

Allow playing of live streamed data #1806

Binozo opened this issue May 26, 2024 · 1 comment

Comments

@Binozo
Copy link

Binozo commented May 26, 2024

Checklist

  • I made sure that the issue I am raising doesn't already exist

Use case / Problem

Hello there 馃憢

currently I am developing an app for my raspberry pi running on flutter-pi. flutter-pi supports only this audio package so that's why I chose it (and it looks decent too).

In this use case the audio data is being live streamed by my server in a format like this: Stream<Uint8List>.
I looked through the wiki and there is no real option for live streamed data beside BytesSource and UrlSource but those only support audio data which is already fully downloaded.

I think it would be a great addition for this package

Proposal / Solution

I would suggest a new type of Source like StreamedBytesSource for example. With that new type you would constantly add data to the buffer which is being read by this package. I think implementing this new type of source and playing the actual data like BytesSource does would be a good way to implement that.

Example Code

Example Code
void main() {
  final player = AudioPlayer();
  // Pseudo stream but could be implemented somehow like this
  Stream<Uint8List> source = // stream init
  await player.setSource(StreamedBytesSource(source));
  // Add data
  source.add([0, 1, 0, 1, 0, 1 /* ... */]); // being fed by an external source
}

Affected platforms

Android, iOS, web, Windows, Linux, macOS

Platform details

I think it'll work on every platform which implements BytesSource because the way it plays the audio could be implemented like BytesSource does.

Audio Files/URLs/Sources

No response

Mockups

No response

Related issues / more information

I think this feature would be a great addition and I'm looking forward to do the actual implementation myself :)

Currently I am planning to wait for some feedback to this feature request until I do the actual implementation

Working on PR

yeah

@Binozo
Copy link
Author

Binozo commented May 29, 2024

Took a look into the internals and it seems that that StreamedBytesSource would need a reimplementation of almost every api 馃槵

Most of those expect a full bytestream to feed into their dedicated audioplayer like android does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant