cast-scanner
Scan your local network for all Chromecast devices.
Originally based on xat/chromecast-scanner.
Installation
npm install dcpesses/cast-scanner
Usage
var scanner = ;
Results can be obtained through either a callback and/or an event.
Simple Callback
;
Event Listener
scanner;
More usage examples can be found in the examples
folder.
API
;
options
: Object (optional)ttl
Number (optional) - Lifespan (in milliseconds) to wait for responses from all devices. Default:5000
mdns
Object (optional) - Config to pass to multicast-dns. Default:{}
debug
: Verbose logging to console. Default:false
callback
Function (optional)
Returns CastScanner instance
Creates a CastScanner instance using any provided options and/or a callback function.
Events
Event: init
Returns:
event
Eventtype
Stringtimestamp
Number - Unix timestamp of when initialization occurred.
Emitted after the module is initialized.
Event: update
Returns:
event
Eventtype
Stringdevice
Object - Chromecast device objectname
String - Local domain namedisplayName
String - Name displayed to usersshortName
Stringhost
Stringip
String - IP address of devicerecords
Object - DNS records received from device like (e.g. "A", "SRV", "TXT", etc)
Emitted when a response is received from a valid casting device.
Event: close
Returns:
event
Eventtype
Stringtimestamp
Number - Unix timestamp of when initialization occurred.duration
Number - Approximate ttl used to wait for device responses.
Emitted when the connection is closed
Event: results
Returns:
event
Eventtype
Stringdevices
Array - All valid Chromecast devices found.
Emitted once the scanner is no longer listening for any more devices and all of the responses have been processed.
Each object in the devices
array uses the same format as the details
object emitted from an 'update' event.
Methods
scanner
Stops waiting for device responses and clears the ttl timeout.
License
MIT