terrabythia / dart_chromecast

Dart package to play videos to a chromecast device
MIT License
62 stars 66 forks source link

castDevice.friendlyName returns as "Unkown" on all iOS devices I've tested on #22

Closed DorsetDevStudio closed 4 years ago

DorsetDevStudio commented 4 years ago

Hi, thanks for publishing this great plugin, I'm using in my streaming app called FarmTUBE (free). The only issue is the friendly name comes back "Unknown" on iPhones/iPads . It still streams fine, it's just an issue selecting the correct device in a house with multiple Chromecasts. I've tested a number of apple phones at different houses with the same result, it works perfectly on Android devices.

I'm using a gen2 Chromecast (i have many of them)

image

image

I would be willing to pay £50 for a fix to this bug as casting is the primary purpose of my app.

Thanks Stuart

terrabythia commented 4 years ago

Hi,

It seems like, for some reason, the GET request to http://192.168.2.2:8008/setup/eureka_info?params=name,device_info always throws an exception on iOS. Maybe because your app is not allowed to request non-https URLs?

You could try allowing insecure HTTP loads in your app, but this is not recommended. I think Apple may even not allow an app to be published in the App Store when it allows HTTP requests.

I did just update the code to only set the device name to 'Unknown' when we didn't already have a name for the device. This might fix your problem. Let me know.

DorsetDevStudio commented 4 years ago

thanks for taking a look, i just pulled the change as no difference. However I am curious, in my console i'm seeing this: I/flutter (24722): found device Name: Chromecast-cde702228a5d2b47e14584f2048908f4, Type: ._googlecast._tcp, HostName: 192.168.1.22, Address: 192.168.1.22, Port: 8009 which says port 8009 ? while that may be a port chromecast uses it not 8008 which is where the GET request needs to go. is it possible your GET request is going to 8009 not 8008 somehow?

Looking at the code all seems legit

'http://${host}:8008/setup/eureka_info?params=name,device_info');

terrabythia commented 4 years ago

No, the eureka_info is on a different port than the actual ChromeCast itself, so that's how it's supposed to be.

Did you run this test on an iOS device? I'm pretty sure the problem is the eureka_info URL not being https.

I've just updated the code to use a https url. Could you try again? It might still not work because the https certificate isn't valid, but maybe iOS doesn't mind that.

DorsetDevStudio commented 4 years ago

Hi, I have found the root cause of the issue, it's not this plugin. The host name returned by ios is some random.local. address, if i ignore that and use the IP it works perfectly in IOS and Android so the fix should be in https://github.com/terrabythia/flutter_chromecast_example (see below)

image

DorsetDevStudio commented 4 years ago

I will test the https implementation now

DorsetDevStudio commented 4 years ago

hi, I have just retested on ios and android, your https update does not fix the original issue but is good (it works). I am only able to resolve the problem by adding this line to the code i'm using from https://github.com/terrabythia/flutter_chromecast_example to force the use of the ip address and not the hostname.

I realise patching that module does not help those using this module so perhaps you have a way to use ip address and not the hostnames from here.

Thanks

image

DorsetDevStudio commented 4 years ago

I'll push an update to my FarmTUBE app shortly which will contain the fix above as proof it works.

terrabythia commented 4 years ago

Of course, this was actually a problem with the MDSN Plugin. Glad you found a solution (all though I don't think the best solution is just assigning the address to the hostName, but I'll look into the issue on the MDNS plugin myself later. 👍

Closing this issue now.