kakone / googlecast Goto Github PK
View Code? Open in Web Editor NEWImplementation of the Google Cast protocol (.NET Standard 2.0 library)
License: GNU General Public License v3.0
Implementation of the Google Cast protocol (.NET Standard 2.0 library)
License: GNU General Public License v3.0
How would we do something like https://demille.github.io/url-cast-receiver/
That is, send an HTML Webpage URL to the chromecast device to have it load and display the webpage?
Also, how do we check the heartbeat?
Thank you
Hey,
have implemented a very basic http server which serves a mp3 file. With your library it also starts playing the music. But now I have the problem that it seems like the chromecast is buffering the entire file directly and playing it. Im using streaming type live. Problem with this is that I write on the fly to this file because im recording sound from a specific application.
Any idea how to prevent chromecast from directly loading the entire file and stopping then?
Kind Regards,
Daniel
Im currently developing an Xamarin Forms-app. Everything works great on Android but im not able to fetch any receivers using: FindReceiversAsync() using IOS and Iphone-device?? Any idea? Need to set any permissions etc ?
In Program1:
var sender = new Sender();
var receiver = new Receiver()
{
IPEndPoint = CreateIPEndPoint(...)
};
// Connect to the Chromecast
await sender.ConnectAsync(receiver);
var channel = sender.GetChannel<IMediaChannel>();
await sender.LaunchAsync(channel);
await channel.LoadAsync(new Media{ ContentId = "http://.../media.mp3"});
(starts playing the media.mp3 file)
Then in Program2:
var sender = new Sender();
var receiver = new Receiver()
{
IPEndPoint = CreateIPEndPoint(...)
};
// Connect to the Chromecast
await sender.ConnectAsync(receiver);
var channel = sender.GetChannel<IMediaChannel>();
await sender.LaunchAsync(channel);
await channel.StopAsync();
Gets an exception about a null MediaSessionId. This is expected since we didn't start the session, but is there a way to stop the already playing stream?
I'm using GoogleCast and it works very well! Thanks for providing this!
My application stores a selected receiver from the list of receivers and casts to that device. Looking at the exposed attributes of IReceiver I see Friendly Name and IPEndPoint - both of which are dynamic. IP addresses will change with DHCP and the Friendly Name is alterable by the user. What I would like to do is store a unique ID for the selected receiver and then use that when it is time to connect. This way the friendly name can be changed at will without affecting anything.
Is it possible to expose a .Id of somekind against each receiver in IReceiver?
Hi,
I have created an application using Xamarin and used a chrome cast in it. Application working fine in Debug mode bug but when await ConnectAsync(selectedcastdevices) call it didn't work in release mode and did not connect to the casting device. I am using the google cast plugin for the chrome cast technique. mac os Catalina 10, iPad 15 version, and vs 2019.
I have done too much research about this issue before posting it here and what I have concluded is 'issue can be of Permission' (debug mode doesn't ask for permission) but in release, it asks and somewhere in this permission section is vulnerable cause it works fine in debug mode as mentioned above
it executed Semaphore.Release() and never come back on release mode and show nothing
In info.plist, NSAppTransportSecurity => NSAllowsArbitraryLoads set to true is already added.
Media A - starts
Media A - ends
Media A - starts
... etc
Hi,
I found your library after you commented on an issue in the SharpCaster repo.
The code looks nice and clean!
Without wanting to judge (you're free to start a new library, and it also gives opportunities to learn from each other), I was curious on why you decided to start from scratch.
I'm curious because maybe you found shortcomings or things you would like to see different in what we did already - I'm interested in such feedback to see where we can improve; also I'm wondering if you'd like to work together in any way since we seem to have the same goals - it could result in less duplicated work.
This isn't meant to be pushy; if you're happy the way things are then it's also fine.
Hi,
I want to use this great code for unity on android. Is this possible?
regards
Noel
Kakone,
Could you please add more channel like YoutubeChannel, WebChannel so i can cast webpage or youtube video to chromecast. Thanhk you.
The Sender.Disconnected event does not seem to fire. If I am connected and playing media if I hit back on my Android TV remote, it exits casting and stops playing the media but my Disconnected event handler is never called. I hook up my event handler after I connect and launch the media channel.
When I try to call LoadAsync() to play an audio file and try to pass in GenericMediaMetadata the Serialization.InvalidDataContractException is thrown with the message:
No set method for property 'MetadataType' in type 'GoogleCast.Models.Media.GenericMediaMetadata'.
The top of the stack trace is:
at System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.InternalSerialize(
I test the package with .NET Maui android app, when i selected the device can't connect due to a exception...
[monodroid-assembly] open_from_bundles: failed to load assembly GoogleCast.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/GoogleCast.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Net.NetworkInformation.dll
[monodroid-assembly] open_from_bundles: failed to load assembly System.Net.Sockets.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Net.NetworkInformation.dll [External]
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Net.Sockets.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Zeroconf.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/Zeroconf.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Reactive.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Reactive.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly Microsoft.Win32.Primitives.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/Microsoft.Win32.Primitives.dll [External]
[s.growingfamily] type=1400 audit(0.0:1203587): avc: denied { ioctl } for path="socket:[2849895]" dev="sockfs" ino=2849895 ioctlcmd=0x8946 scontext=u:r:untrusted_app:s0:c244,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c244,c256,c512,c768 tclass=udp_socket permissive=0
[monodroid-assembly] open_from_bundles: failed to load assembly System.Threading.ThreadPool.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Threading.ThreadPool.dll [External]
Thread started: .NET Sockets #12
[Choreographer] Skipped 37 frames! The application may be doing too much work on its main thread.
[mali_winsys] EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
[monodroid-assembly] open_from_bundles: failed to load assembly System.Net.Security.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Net.Security.dll [External]
[monodroid-assembly] open_from_bundles: failed to load assembly System.Security.Cryptography.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Security.Cryptography.dll [External]
[libEGL] EGLNativeWindowType 0xcd21b008 disconnect failed
[InputEventReceiver] Attempted to finish an input event but the input event receiver has already been disposed.
[monodroid-assembly] open_from_bundles: failed to load assembly System.Collections.NonGeneric.dll
Loaded assembly: /data/data/com.alphas.growingfamily/files/.__override__/System.Collections.NonGeneric.dll [External]
[System.err] javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
[System.err] at com.google.android.gms.org.conscrypt.SSLUtils.toSSLHandshakeException(:com.google.android.gms@[email protected] (100300-511787759):2)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.convertException(:com.google.android.gms@[email protected] (100300-511787759):1)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.readPlaintextData(:com.google.android.gms@[email protected] (100300-511787759):4)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.unwrap(:com.google.android.gms@[email protected] (100300-511787759):30)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.unwrap(:com.google.android.gms@[email protected] (100300-511787759):46)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.unwrap(:com.google.android.gms@[email protected] (100300-511787759):2)
[System.err] at mono.java.lang.RunnableImplementor.n_run(Native Method)
[System.err] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:31)
[System.err] at android.os.Handler.handleCallback(Handler.java:873)
[System.err] at android.os.Handler.dispatchMessage(Handler.java:99)
[System.err] at android.os.Looper.loop(Looper.java:211)
[System.err] at android.app.ActivityThread.main(ActivityThread.java:6769)
[System.err] at java.lang.reflect.Method.invoke(Native Method)
[System.err] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[System.err] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[System.err] Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
[System.err] at com.android.org.conscrypt.TrustManagerImpl.verifyChain(TrustManagerImpl.java:668)
[System.err] at com.android.org.conscrypt.TrustManagerImpl.checkTrustedRecursive(TrustManagerImpl.java:546)
[System.err] at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:502)
[System.err] at com.android.org.conscrypt.TrustManagerImpl.checkTrusted(TrustManagerImpl.java:425)
[System.err] at com.android.org.conscrypt.TrustManagerImpl.getTrustedChainForServer(TrustManagerImpl.java:360)
[System.err] at android.security.net.config.NetworkSecurityTrustManager.checkServerTrusted(NetworkSecurityTrustManager.java:102)
[System.err] at android.security.net.config.RootTrustManager.checkServerTrusted(RootTrustManager.java:104)
[System.err] at java.lang.reflect.Method.invoke(Native Method)
[System.err] at com.google.android.gms.org.conscrypt.Platform.checkTrusted(:com.google.android.gms@[email protected] (100300-511787759):2)
[System.err] at com.google.android.gms.org.conscrypt.Platform.checkServerTrusted(:com.google.android.gms@[email protected] (100300-511787759):5)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.verifyCertificateChain(:com.google.android.gms@[email protected] (100300-511787759):6)
[System.err] at com.google.android.gms.org.conscrypt.NativeCrypto.ENGINE_SSL_read_direct(Native Method)
[System.err] at com.google.android.gms.org.conscrypt.NativeSsl.readDirectByteBuffer(:com.google.android.gms@[email protected] (100300-511787759):2)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.readPlaintextDataDirect(:com.google.android.gms@[email protected] (100300-511787759):0)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.readPlaintextDataHeap(:com.google.android.gms@[email protected] (100300-511787759):3)
[System.err] at com.google.android.gms.org.conscrypt.ConscryptEngine.readPlaintextData(:com.google.android.gms@[email protected] (100300-511787759):3)
[System.err] ... 12 more
[System.err] Caused by: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
[System.err] ... 28 more
[monodroid-assembly] open_from_bundles: failed to load assembly es-419/System.Net.Security.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly es-419/System.Net.Security.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly es/System.Net.Security.resources.dll
[monodroid-assembly] open_from_bundles: failed to load assembly es/System.Net.Security.resources.dll
[DOTNET] Authentication failed, see inner exception.
Hey, sorry I am new to chrome cast and want to use this in a project. Is it possible to use a custom receiver application using this technique? I want to send bare byte data to display images. Thanks in advance!
Would this SDK be able to control / stream to a Google Home Mini?
First of all, thanks very much for your work on this and making it available to the rest of us.
I can't see how to set the volume for the receiver? I do see a GoogleCast.Messages.Receiver.SetVolumeMessage class in the source code but there appears to be no "GoogleCast.Messages.Receiver" namespace in the NuGet package?
Also, is there an easy way to have a custom name and logo for the receiver? When my app connects it just displays a generic casting logo on the TV screen (Android TV) when waiting to play media. It would be great to display my app's logo there. Likewise, the casting notification on my local devices shows casting to "Default Media Receiver". Is there an easy way to rename this?
Hi there, does this project only implement the sender side?
I set the SubTitle property of the Metadata info of the media but subtitles never show.
var media = new Media
{
ContentId = isRemote ? MediaPath : mediaPath,
ContentType = "video/mp4",
Metadata = new MovieMetadata
{
Title = MediaName,
SubTitle = !string.IsNullOrEmpty(subtitle) ? subtitle : null
}
};
subtitle variable is http://192.168.1.11/Subtitles%2Ftt3606752%2FCars%203%20NEW%20HD-TS%20x264-CPG.vtt (URI encoded to my local server which serves .vtt static files with CORS, as required by Chromecast https://developers.google.com/cast/docs/media.
There is no Track property to the loaded media, which is the required way to load subtitles as explained https://developers.google.com/cast/docs/chrome_sender_advanced
Of the various Chromecasting libraries for C#/Xamarin, yours appears to be the only modern (DotNet Standard 2.0) one. When it came to choosing one for my project, I went for sharpcaster as you all had roughly the same last commit dates and they seemed to have a few more features. Having switched to Xamarin.Forms 4 now, I see that they are rather out of date and (probably) nothing built with them will get onto the Apple app store these days (API issues). Is there any way you could commit some/anything just to give the casual browser some indication that yours is still active and the way to go. I replaced Sharpcaster with your library in an hour with about half the code.
Thanks
Shaun
I can load a queue of media items successfully, but I don't see any way to control the playback of the queue after this. That is, are there next/previous commands, get/set current index in queue, etc.? Thanks.
never mind - silly issue on my part - I just can't seem to delete this post
Hi, I would like to send and receive normal string messages. Is this possible as well? Thanks!
zeroconf since v2.9.0 can find device continuous with methode "ResolveContinuous". Please add this method to Devicelocator. thank you.
I have an older iPhone 5s running iOS 12 that consistently finds all cast receivers. An iPad running iOS 14 never finds any. Both are connected to the same WiFi and don't have any cellular connection. Any ideas?
Hi,
I used this library with Xamarin Form and it work. Thank you for that.
But It's only work with the online URL, when I try a local file in my Android device E.g.
var sender = new Sender();
// Connect to the Chromecast
await sender.ConnectAsync(receiver);
// Launch the default media receiver application
var mediaChannel = sender.GetChannel();
await sender.LaunchAsync(mediaChannel);
var mediaStatus = await mediaChannel.LoadAsync(new MediaInformation() { ContentId = "/storage/emulated/0/Download/BigBuckBunny.mp4" });
It does not work.
Can you please help?
Greetings!
First off this is an awesome project, very modern and clean code. I am working on a .Net Core 2.0 Console service that utilizes MQTT for communications and acts as a hub for much of my home automation. I've been attempting to add a chromecast project to the service that utilizes this library. Using the example provided I've been able to connect and Play media, however, before attempting to execute other commands such as PauseAsync()
and StopAsync()
I check an IsStopped
boolean just like in the example.
public bool IsStopped
{
get
{
var mediaChannel = _sender?.GetChannel<IMediaChannel>();
return (mediaChannel?.Status == null || !String.IsNullOrEmpty(mediaChannel.Status.FirstOrDefault()?.IdleReason));
}
}
When doing so the mediaChannel.Status
is always null.
When I do _sender.GetStatuses()
I get two entries in the Dictionary. One with Key = "urn:x-cast:com.google.cast.receiver"
and the other Key = "urn:x-cast:com.google.cast.media"
both with null values.
Is there something I'm missing that's happening in the example?
I am playing the sample video (Big Buck Bunny) and MediaStatus.CurrentTime is not updated until the PlayerState is toggled. That is, repeated calls to IMediaChannel.Status result in the same CurrentTime until the video is paused at which point it is updated. Is there a way to get this to update while playing?
Also, it looks like the only way to retrieve the video duration is through MediaStatus.Media.Duration but MediaStatus.Media is null?
Thanks.
Is it possible to use with Xamarin Forms? If yes, how?
(Possibly related to #22 )
My desktop has a large number of network interfaces, caused by the Hyper-V role and a large amount of created internal switches.
When scanning for devices using DeviceLocator, it is unable to find any devices. This seems to be due to the fact that the wrong interface is used to scan for devices.
To verify, I tried using SharpCaster.
I get the same result; no devices found when using the default constructor on DeviceLocator. However, SharpCaster allows me to specify a source IP address in the constructor. When using that specific IP address, my devices are found. Unfortunately, that module is not compatible with .NET Standard.
It would be great if a similar constructor is available in GoogleCast.
I have no problem with loading the subtitles in the example project, but it seems like it only takes .vtt and not .srt subtitle files. Is this a bug or not yet implemented?
They are very similar, so I could easily download and convert the .srt file to a .vtt file but then I can't get it to load the subtitle file because it is a local file and not available on the internet via a link. How do you fix this?
Setting metadata throws exception:
var mediaInfo = new MediaInformation
{
ContentId = link,
ContentType = mimeType,
StreamType = StreamType.Buffered,
Metadata = new GenericMediaMetadata
{
Title = "Sample",
Subtitle = "subtitle",
Images = new[]
{
new Image{Url = thumbUrl}
}
}
};
Hi Stéphane,
When calling the FindReceiversAsync()
method, an empty list is returned.
My computer is connected to the same network as my ChromeCast and Google Home mini devices. I can see them if I try to cast from chrome, for example.
Could you give me advice on how to further debug this problem?
EDIT: When I try this on my laptop (which is on the WIFI) it doesn't work, but on my desktop (which is wired) it does find the devices.
Thanks,
Morten
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.