playStream method
override
Stream audio chunks to this audio output device for playback.
The caller provides a Stream of raw audio bytes; each chunk must match
the codec and format described by audioInfo. Playback begins on the
device as chunks arrive, before the stream is exhausted.
Implementation
@override
Future<PlayStreamResponse> playStream({
required AudioInfo audioInfo,
required Stream<Uint8List> audioStream,
Map<String, dynamic>? extra,
}) async {
final init = PlayStreamRequest()
..init = (PlayStreamInit()
..name = name
..audioInfo = audioInfo
..extra = extra?.toStruct() ?? Struct());
Stream<PlayStreamRequest> requests() async* {
yield init;
await for (final chunk in audioStream) {
yield PlayStreamRequest()..audioChunk = (PlayStreamChunk()..audioData = chunk);
}
}
return await client.playStream(requests());
}