Allow playing of live streamed data
Binozo opened this issue ยท 1 comments
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
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