Last active
April 26, 2023 19:08
-
-
Save skittleson/095c0e9a4d56fbc53b80d22029e90c9b to your computer and use it in GitHub Desktop.
Cross platform audio player in dotnet
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(); | |
} |
spencerkittleson
commented
Apr 26, 2023
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment