|
1 | | - |
| 1 | + |
| 2 | + |
2 | 3 | # SharpCaster |
3 | 4 |
|
4 | | -### Currently Supported Platforms |
5 | | -* [.NET Standard 2.0](https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0) |
| 5 | +[](https://github.com/Tapanila/SharpCaster/actions/workflows/dotnet.yml) |
| 6 | +[](https://www.nuget.org/packages/SharpCaster/) |
| 7 | + |
| 8 | +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. |
| 9 | + |
| 10 | +--- |
6 | 11 |
|
7 | | -[](https://github.com/Tapanila/SharpCaster/actions/workflows/dotnet.yml) |
| 12 | +## Features |
| 13 | +- Discover Chromecast devices on your local network |
| 14 | +- Connect and launch applications on Chromecast |
| 15 | +- Load and control media playback (play, pause, stop, etc.) |
| 16 | +- Support for custom Chromecast channels |
| 17 | +- Compatible with .NET Standard 2.0 and .NET 9 |
8 | 18 |
|
9 | | -SharpCaster is Chromecast C# SDK any platform support .net standard 2.0. |
| 19 | +--- |
10 | 20 |
|
11 | | -## The nuget package [](https://www.nuget.org/packages/SharpCaster/) |
| 21 | +## Supported Platforms |
| 22 | +- [.NET Standard 2.0](https://docs.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0) |
| 23 | +- [.NET 9](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) |
12 | 24 |
|
13 | | -https://nuget.org/packages/SharpCaster/ |
| 25 | +--- |
14 | 26 |
|
15 | | - PM> Install-Package SharpCaster |
| 27 | +## Installation |
| 28 | +Install the NuGet package: |
| 29 | +PM> Install-Package SharpCaster |
| 30 | +Or via .NET CLI: |
| 31 | +dotnet add package SharpCaster |
| 32 | +[NuGet Gallery](https://nuget.org/packages/SharpCaster/) |
16 | 33 |
|
17 | | -# Getting started |
| 34 | +--- |
18 | 35 |
|
19 | | -## Finding chromecast devices from network |
20 | | -```cs |
21 | | -IChromecastLocator locator = new MdnsChromecastLocator(); |
| 36 | +## Getting Started |
| 37 | + |
| 38 | +### 1. Discover Chromecast DevicesIChromecastLocator locator = new MdnsChromecastLocator(); |
22 | 39 | var source = new CancellationTokenSource(TimeSpan.FromMilliseconds(1500)); |
23 | 40 | var chromecasts = await locator.FindReceiversAsync(source.Token); |
24 | | -``` |
25 | | -## Connecting to chromecast device, launch application and load media |
26 | | -```cs |
27 | | -var chromecast = chromecasts.First(); |
| 41 | +### 2. Connect, Launch App, and Load Mediavar chromecast = chromecasts.First(); |
28 | 42 | var client = new ChromecastClient(); |
29 | 43 | await client.ConnectChromecast(chromecast); |
30 | | -_ = await client.LaunchApplicationAsync("B3419EF5"); |
| 44 | +await client.LaunchApplicationAsync("B3419EF5"); // Replace with your app ID |
31 | 45 |
|
32 | 46 | var media = new Media |
33 | 47 | { |
34 | | - ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4" |
| 48 | + ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4" |
35 | 49 | }; |
36 | | -_ = await client.MediaChannel.LoadAsync(media); |
37 | | -``` |
| 50 | +await client.MediaChannel.LoadAsync(media); |
| 51 | +--- |
38 | 52 |
|
39 | | -## SharpCaster Demo |
| 53 | +## Demo |
40 | 54 |
|
41 | 55 |  |
42 | 56 |
|
43 | | -## Adding support for custom chromecast channels |
44 | | - |
45 | | - * In Chrome, go to `chrome://net-export/` |
46 | | - * Select 'Include raw bytes (will include cookies and credentials)' |
47 | | - * Click 'Start Logging to Disk' |
48 | | - * Open a new tab, browse to your favorite application on the web that has Chromecast support and start casting. |
49 | | - * Go back to the tab that is capturing events and click on stop. |
50 | | - * Open https://netlog-viewer.appspot.com/ and select your event log file. |
51 | | - * Browse to https://netlog-viewer.appspot.com/#events&q=type:SOCKET, and find the socket that has familiar JSON data. |
52 | | - * Go through the results and collect the JSON that is exchanged. |
53 | | - * Now you can create a new class that inherits from ChromecastChannel and implement the logic to send and receive messages. |
| 57 | +--- |
| 58 | + |
| 59 | +## Custom Chromecast Channels |
| 60 | + |
| 61 | +You can add support for custom Chromecast channels by reverse engineering the communication: |
| 62 | + |
| 63 | +1. In Chrome, go to `chrome://net-export/` |
| 64 | +2. Select 'Include raw bytes (will include cookies and credentials)' |
| 65 | +3. Click 'Start Logging to Disk' |
| 66 | +4. Cast from your favorite web app |
| 67 | +5. Stop logging and open the log in [netlog-viewer](https://netlog-viewer.appspot.com/) |
| 68 | +6. Search for `type:SOCKET` and find familiar JSON data |
| 69 | +7. Collect the exchanged JSON |
| 70 | +8. Create a new class inheriting from `ChromecastChannel` and implement your logic |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## Contributing |
| 75 | +Contributions, issues, and feature requests are welcome! Feel free to open an issue or submit a pull request. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## License |
| 80 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
0 commit comments