LLibVLC Chromecast Discovering

This forum is about all development around libVLC.
Semola
New Cone
New Cone
Posts: 2
Joined: 15 Nov 2019 13:21

LLibVLC Chromecast Discovering

Postby Semola » 16 Feb 2022 21:28

Hi All,

I wrote a simple class that using LibVLCSharp (ver. 3.6.5.0) for discover any chromecast in my local network.
The caller, inizialize the class, then call the "DiscoverChromecasts" method to search chromecast
If I run the attached code in my home, I found 2 items. If I try to run the code in my brother's home, i cannot discover any chromecast (but it is visible from Chrome or Youtube application).
I don't understand why it works perfectly for me, while it doesn't go to my brother

Can anyone help me?
Thanks

Semola

Code: Select all

public class ChrVLC { LibVLC _libVLC; RendererDiscoverer _rendererDiscoverer; readonly HashSet<RendererItem> _rendererItems = new HashSet<RendererItem>(); private List<String> messages; public ChrVLC() { Core.Initialize(); _libVLC = new LibVLC(); messages = new List<string>(); } public HashSet<String> DiscoverChromecasts() { messages.Clear(); HashSet<String> returnValue = new HashSet<String>(); // create a renderer discoverer _rendererDiscoverer = new RendererDiscoverer(_libVLC); // register callback when a new renderer is found _rendererDiscoverer.ItemAdded += RendererDiscoverer_ItemAdded; // start discovery on the local network _rendererDiscoverer.Start(); Thread.Sleep(500); foreach (RendererItem item in _rendererItems) { messages.Add($"Added {item.Name} - {item.IconUri}"); returnValue.Add(item.Name); } return returnValue; } private void RendererDiscoverer_ItemAdded(object sender, RendererDiscovererItemAddedEventArgs e) { messages.Add($"New item discovered: { e.RendererItem.Name} of type { e.RendererItem.Type} "); messages.Add($" iconUri: {e.RendererItem.IconUri}"); if (e.RendererItem.CanRenderVideo) { messages.Add($"{e.RendererItem.Name} - Can render video"); } if (e.RendererItem.CanRenderAudio) { messages.Add($"{e.RendererItem.Name} - Can render audio"); } _rendererItems.Add(e.RendererItem); } public List<String> getNessages() { return messages; } public string RenderIpAddress(String rendererItem) { String ipAddress = String.Empty; messages.Clear(); foreach (RendererItem _item in _rendererItems) { messages.Add($"Scan {_item.Name} - IconUri: {_item.IconUri}"); if (_item.Name.Equals(rendererItem)) { int lastPos = 0; ipAddress= _item.IconUri.Replace("http://", "").Replace("https://", ""); lastPos = ipAddress.IndexOf(":"); if (lastPos < 0) { lastPos = ipAddress.IndexOf("/"); } if (lastPos > 0) { ipAddress = ipAddress.Substring(0, lastPos); } messages.Add($"Match {_item.Name} - iconUri: {_item.IconUri} - ipAddress: {ipAddress}"); } } return ipAddress; } public string RendererType(String rendererItem) { foreach (RendererItem _item in _rendererItems) { if (_item.Name.Equals(rendererItem)) { return _item.Type; } } return string.Empty; } }

mfkl
Developer
Developer
Posts: 740
Joined: 13 Jun 2017 10:41

Re: LLibVLC Chromecast Discovering

Postby mfkl » 21 Feb 2022 08:46

Difficult to say if we cannot reproduce locally.

Does the official VLC apps (desktop, ios or android) find the chromecast at your brother's place? If so, problem is on your side.

Are the chromecast devices the same hardware running the same software version?
Are you using a VPN on your brother computer? If so, discovery won't be possible.
Is the wifi router allowing such discovery?

We will need logs too.
https://mfkl.github.io

unidan
Developer
Developer
Posts: 1493
Joined: 25 Mar 2018 01:00

Re: LLibVLC Chromecast Discovering

Postby unidan » 28 Apr 2022 22:14

What is the OS you're running on too? If it's windows, is the network connection type in public or in private?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 3 guests