chromecast-scanner
chromecast-scanner copied to clipboard
Can i get the chromecast friendly name?
Hi!
Is possible to get the friendly chromecast name? The service object looks like:
{
name: '9098057d-0d67-523d-56df-0b048c5f01e3.local',
type: 'A',
class: 32769,
ttl: 120,
data: '192.168.1.XXX'
}
But i want to get the name that appears in apps like Youtube, in my case is 'CaneloChromecast'. How can i get this?
Thanks!
Try running this:
var scanner = require('chromecast-scanner');
var txt = require('dns-txt')();
scanner((err, service, response) => {
var info = response.additionals.find(entry => entry.type === 'TXT');
var name = txt.decode(info.data).fn;
console.log(name);
});
@xat - I'd be happy to include a PR for this library so that the friendly name can be scanned, as well.
Right now, opts.name matches the name of the A record. I propose we add opts.friendlyName that matches the fn service key entry in the TXT record as suggested by @Rafostar above. This will be the user-defined name for the Chromecast that users probably prefer.
My goal here is that castnow could be modified to prefer scanning by the friendly name. Thoughts?