Streaming audio chunks on web & mobiles?

Hey everyone!

I’m trying to stream audio chunks (Uint8List) from OpenAI’s TTS model (tts-1) and play them in real-time. I'm using the audioplayers package, which doesn’t support streaming directly. To work around this, I’m creating a buffer to play chunks sequentially, mimicking the effect of real-time audio.

The first chunk plays fine, but subsequent chunks fail with errors like:
- DEMUXER_ERROR_COULD_NOT_OPEN
- NotSupportedError

I suspect the issue lies in how I’m buffering the audio, possibly creating corrupted chunks. Here’s the buffer handling code:

```dart void _addToBuffer(Uint8List chunk) { _currentBuffer.add(chunk); }

void _flushBufferToQueue() { if (_currentBuffer.isNotEmpty) { _bufferQueue.add(_currentBuffer.toBytes()); _currentBuffer.clear(); } } ```

Here’s a video demo of the issue, and the full code is on GitHub.

Has anyone successfully streamed and played audio in real time on web or mobile? Any advice or alternative solutions would be super helpful!