Cross-platform .NET SDK for Google Chromecast with media control, queue management, and Native AOT support. Discover devices, stream media, and build custom Cast applications with async/await APIs.
$ dotnet add package Sharpcaster
SharpCaster is a cross-platform C# SDK for communicating with Google Chromecast devices. It enables .NET applications to discover, connect, launch apps, and control media playback on Chromecast devices.
DevicesIChromecastLocator locator = new MdnsChromecastLocator();
var source = new CancellationTokenSource(TimeSpan.FromMilliseconds(1500));
var chromecasts = await locator.FindReceiversAsync(source.Token);
var chromecast = chromecasts.First();
var client = new ChromecastClient();
await client.ConnectChromecast(chromecast);
await client.LaunchApplicationAsync("B3419EF5"); // Replace with your app ID
var media = new Media
{
ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
};
await client.MediaChannel.LoadAsync(media);
You can add support for custom Chromecast channels by reverse engineering the communication:
chrome://net-export/type:SOCKET and find familiar JSON dataChromecastChannel and implement your logicContributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.