Code Monkey home page Code Monkey logo

sharpcaster's Introduction

Icon

SharpCaster

Currently Supported Platforms

.NET

This project is completed

I won't be adding any new features to this project. SharpCaster is Chromecast C# SDK any platform support .net standard 2.0.

The nuget package NuGet Status

https://nuget.org/packages/SharpCaster/

PM> Install-Package SharpCaster

Getting started

Finding chromecast devices from network

IChromecastLocator locator = new MdnsChromecastLocator();
var chromecasts = await locator.FindReceiversAsync();
//If that does not return devices on desktop then you can use this, Where 192.168.1.2 is your machines local ip
var chromecasts = await locator.FindReceiversAsync("192.168.1.2");

Connecting to chromecast device, launch application and load media

var chromecast = chromecasts.First();
var client = new ChromecastClient();
await client.ConnectChromecast(chromecast);
_ = await client.LaunchApplicationAsync("B3419EF5");

var media = new Media
{
	ContentUrl = "https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/DesigningForGoogleCast.mp4"
};
_ = await client.GetChannel<IMediaChannel>().LoadAsync(media);

SharpCaster Demo

SharpCaster Simple demo

sharpcaster's People

Contributors

dependabot[bot] avatar hansmbakker avatar highwingers avatar kalpesh2804 avatar poumason avatar robertk66 avatar tapanila avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sharpcaster's Issues

Idea: support for popular chromecast apps

The current library targets Google's Default Media Receiver (message format and available operations).

However it would be nice if additional apps with their own protocol could be supported.

My idea would be something like this:

  • Allow the ChromeCastClient client to use different controller implementations
  • Register controller implementations along with their respective AppId
  • Let ChromeCastClient automatically load the right controller for the current app

@Tapanila what do you think?

Also have a look at home-assistant-libs/pychromecast#101 (here I implemented a controller for DS Audio)

Difficult ReceiverChannel logic

I'm having difficulty following the logic in ReceiverChannel.

  • Why is await ConnectToApplication(Client.ChromecastApplicationId); called upon every ChromecastStatusResponse?
  • Is it possible to have one ChromecastClient.ChromecastApplication(Id) that is updated upon receiving a ChromecastStatusResponse instead of manually setting it after launching an app? That way the currrent application id would always be filled with an up-to-date value.
  • The need for two similar variables (Client.ChromecastApplicationId vs ChromecastClient.RunningApplication.AppId) confuses me

How put Media Title in metadata object

I have a question, how can I put the title movie in the metadata object, but i dont have the mediatype numbers

GENERIC
Generic template suitable for most media types. Used by chrome.cast.media.GenericMediaMetadata.
MOVIE
A full length movie. Used by chrome.cast.media.MovieMediaMetadata.
TV_SHOW
An episode of a TV series. Used by chrome.cast.media.TvShowMediaMetadata.
MUSIC_TRACK
A music track. Used by chrome.cast.media.MusicTrackMediaMetadata.
PHOTO
Photo. Used by chrome.cast.media.PhotoMediaMetadata.

the MovieMetadata object need a int, do you know the numbers in int?

Chromecast Connect Error

Hey,

first big thx for this SDK it works nice. I hope it´s just my bad, cause i can´t connect to the chromecast.

I have a listbox with all Chromecast and this works well:

` private async void getChromecasts()
{
DeviceLocator deviceLocator = new DeviceLocator();
var cancellationTokenSource = new CancellationTokenSource();
cancellationTokenSource.CancelAfter(5000);
chromecasts = await deviceLocator.LocateDevicesAsync(cancellationTokenSource.Token);

        if(chromecasts.Count > 0)
        {
            foreach (Chromecast chromcast in chromecasts)
            {
                chromecastListBox.Items.Add(new ListBoxItem { Content = chromcast.FriendlyName, Tag = chromcast.DeviceUri });
            }
        }
        else
        {
            chromecastListBox.Items.Add(new ListBoxItem() { IsEnabled = false, Name = "noDevice", Content = "Keine Geräte gefunden" });
        }
        chromecastListBox.Items.Remove(search);
    }`

After that i can push the button to connect to the chromecast:

private void ConnectChromecast(object sender, RoutedEventArgs e) { ListBoxItem selectedChromecast = (ListBoxItem)chromecastListBox.SelectedItem; Testo.Text = selectedChromecast.Tag.ToString(); client.ConnectChromecast(chromecasts.Last().DeviceUri); }

I´ve also tried to set the DeviceUri manuell, but no way. Pls help me ;)

Mfg
Lukas

BTW i add the full code in the attachment
code.txt

Fix builds & Nuget packaging

Currently it builds Portable, .net45 and Universal into same folder and same name. This causes multiple problems and should be fixed.

A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider. (Exception from HRESULT: 0x800B0109)

at Sockets.Plugin.NativeExceptionExtensions.<>c__DisplayClass0_0.b__1(Task1 t) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SharpCaster.Services.ChromecastSocketService.d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at SharpCaster.ChromeCastClient.d__55.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)
at System.Threading.WinRTSynchronizationContext.Invoker.InvokeCore()

In my project use the Nuget version and new master, when I connect the chromecast v1, always get the exception.

Xamarin.iOS Validation

  • Check discovering chromecast
  • Check connecting to chromecast
  • Check starting application
  • Check loading media

.

Xamarin Android Validation

  • Check discovering chromecast
  • Check connecting to chromecast
  • Check starting application
  • Check loading media

This is because of SSL error on socket (Chromecast uses self signed certificates)

Crash when I connect to chromecast

My uwp app crash when i try connect to chromecast.
I select device and try to connect then ( Uri and friendlyName is correct).
Error message : (CoreCLR: CoreCLR_UWP_Domain) : Chargé 'Anonymously Hosted DynamicMethods Assembly'.

thanks
PS, sorry for my english :(

_socket throws NullReferenceException

For some reason I get a nullReferenceException when running the Simple app and sending a message (by changing the volume or clicking play/pause).

Reproduction:

  • run a song in DS Audio on Chromecast
  • run the SharpCaster.Simple app
  • click in the volume slider or click play/pause

Symptoms:

  • Volume slider is zero
  • Volume updates are not received
  • NullReferenceException: _socket is null in ChromecastSocketService.cs (in SharpCaster.UniversalWindows) - this is on line 54 in Write(byte[] bytes)

Issues with protobuf-net

Two issues:

  • When I reference the nuget package (0.1.5) from a blank UWP app then the protobuf-net library is not copied or referenced. Because of that I couldn't build my app with only the nuget package.
  • Besides that I think it is not a good practice to put dll's in git. Is there maybe a Nuget version of the protobuf library available?

Google is working on one but that one seems to only support the proto3 version. Protobuf-net is also a nuget package but it seems there is some issue with the chosen target framework.

MusicTrackMediaMetadata does not display (album)artist

MusicTrackMediaMetadata does not display (album)artist

VB.NET:
metadata = New MusicTrackMediaMetadata() With { .albumArtist = artist, .artist = artist, .songName = song, .title = song }

Both "artist" and "song" have a value, the song is getting displayed on my screen correctly but the artist isn't.

Subtitle or Caption supporting?

Hi, can sharpcaster supporting caption or subtitles? I cant find MediaTracks option just CustomData,

Im a C# .net develop and xamarin too, im looking to cast witth captions or subtitles, i see that you using json to send to chromecast messages, should be good send the subtitle url there too, i have been using Google Services Cast but i dont like it, I like your develop to using in xamarin, but i need captions too. thanks for your work, can you tell me where or a suggestion to add subtitles to the sharpcaster?

Automated testing with Chromecast

I plan to start hosting a build agent with access to chromecast. That way we can always run automated test suite to make sure all the features keep working.

Features that should be tested:

  • Connecting to a chromecast
  • Launching application
  • Rejoining existing application session
  • Closing application
  • Load media
  • Seek
  • Play/Pause
  • Stop
  • Verify metadata after load media
  • Playback working (Check that playback starts after load media)
  • Error handling (Need way to produce them and then make sure we catch them)

Create nuget package

Make it easier to consume this library by creating a nuget package definition and use appvoyer to publish it.

Cast Button (Templated control)

Create templated control of Cast Button that implements Chromecast Design Checklist
https://developers.google.com/cast/docs/design_checklist#cast-button

  • Unavailable: While Cast receivers are not available, the Cast button does not appear
  • Disconnected: While Cast receivers are available, the Cast button appears
  • Connecting: While the Cast receiver is connecting, the Cast button animates the waves in the icon progressively
  • Connected: While this app is connected to the Cast receiver, its Cast button appears with a filled frame shape

Custom App Channel possible?

Hey!
I'm trying to extend the MediaPlayer in a Windows 10 UWP App with SharpCaster to a Chromecast.

I have built a custom receiver app, that communicates via a channel with my app. On Android, this works perfectly but I can't find how to open app channels with SharpCaster, Creating a channel with the ChromecastChannel(client, "NS") does not work for me... My code:

chromecastClient.ApplicationStarted += (sender, application) =>
{
     var ch = new ChromecastChannel("*myappchannel*");
     ch.MessageReceived += (o, args) =>
     {
          Debugger.Break(); //Never triggered
     };
     var msg = new CastMessage { PayloadUtf8 = "{\"type\": \"MOVIE\", \"url\": \"myurl\"}" };
     await ch.Write(msg);
};

Documentation

  • Document creating new Controller
  • Document creating new Channel
  • Document all existing Controllers and Channels
  • Document all LoadMedia parameters (example metadata, duration, streamtype and etc)

Does not work on Windows 10 Iot

I installed the latest SharpCaster nuget package on a Windows 10 IOT background task project.
On ChromecastService.Current.StartLocatingDevices I get the following error:

Could not load file or assembly 'Rssdp.Portable, Version=2.0.0.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The Rssdp.Portable.dll which is distributed in Rssdp-sharpcaster is version 1.0.0.12

Portable Sockets

Hi,

I stumbled upon your great project while researching options on supporting chromecast in windows apps.

A suggestion for future work would be to use already existing portable abstractions of UDP and TCP sockets (e.g. https://github.com/rdavisau/sockets-for-pcl which i've bee successfully working with)

I'm looking forward to future features.

Greetings

Casting a web page

There has been few requests to cast a webpage.
This would probably need to build custom receiver which you can control to open web page

Play a .mp4 File

With Android & Chromecast its possible to play .mp4 files. But if i try to load a mp4 file nothing happens.

client.Connected += async delegate { await client.LaunchApplication("B3419EF5"); }; client.ApplicationStarted += async delegate { await client.LoadMedia("http://www.w3schools.com/html/mov_bbb.mp4"); }; client.ConnectChromecast(new Uri(selectedChromecast.Tag.ToString()));

I still just see "SharpCaster demo receiver" :/

I hope you can help me.

Dear
Lukas

Stop

SDK should enable killing of the application. Chromecast calls this stop

Not able to reference SharpCaster after installing Nuget Package

Hello,

I have a problem using this application, and I am almost sure that I'm missing something really trivial.
I use the nuget command to add SharpCaster, all is great, it installs and adds SharpCaster and Newtonsoft Json, all good.

Now I want to reference it at the top of my application, like: Using Sharpcaster.... But I am not able to find it... It would be a huge relief if you could help.

Plex & Chromecast?

This is more of a question!

I was looking at #50 and just out of curiosity, not directly pointed at @Wind-rider, what do Plex command have to do with Chomecast?

Wouldn't this pollute the project? I myself am a fan of having projects do one thing, and do it good... Having al kinds of features usually makes it hard to maintain, and e.g. a plex change would make other people upgrade the library without the need. Would the Plex stuff work when it was removed from the project into a different one?

Nothing against the functionality... keep up the good work!

Add seekable timeline to sample

Add timeline to sample where user can see how far into the media clip they are and use it to seek to different part of the media clip.

Drive multiple chromecasts

Hi,

Is it possible to control many chromecasts from the same application ?

It seams that your lib is built "single chromecast", but I would like to drive two or three from the same application...

Singleton instance getter is not thread safe

There maybe other but instance property like this is not thread safe. Because of this possible race condition you might create multiple instances if it's called from multiple threads.

public static ChromecastService Current => _instance ?? (_instance = new ChromecastService());

use this instead

private static Lazy<ChromecastService> _current = new Lazy<ChromecastService>(() => new ChromecastService());  
public static ChromecastService Current { get { return _current .Value; } }

Use one solution for Continuous Integration and samples

Now there are two solutions (one general one and one for CI).

It would be better to have only one only one .sln file.

I think this can be done in the following way:

  • Use the solution configuration manager to create a specific "solution configuration" for CI
  • Within that solution configration, uncheck "build" for all sample projects
  • Configure AppVeyor to use the CI solution configuration instead of "Debug" or "Release". See https://www.appveyor.com/docs/build-configuration#build-matrix

I have no AppVeyor account so I couldn't test it, but I think that should work.

custom controller

hi, how can i implement a custom controller to stream a wpf application window?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.