This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // I've used a lot of libs including the popular ones for dotnet such as NAudio but all seem to be overly complicated or not cross platform. | |
| // 1. install ffplay on your platform. for Windows `choco install ffplay`. Debian `apt install ffmpeg`. | |
| // 2. install nuget pkg `CliWrap` | |
| // 3. send your audio stream to the method. | |
| public static async Task PlayAsync(Stream stream, CancellationToken cancellationToken) | |
| { | |
| var result = await Cli.Wrap("ffplay") | |
| .WithStandardInputPipe(PipeSource.FromStream(stream)) | |
| .WithArguments($"-autoexit -nodisp -hide_banner -loglevel error -fs -") | |
| .ExecuteAsync(); | |
| } |