Player APIs (BrightScript & Ja...
JavaScript APIs

usbhotplug

5min
the usbhotplug object can be used to generate events when usb devices are added or removed usbhotplug idl interface usbhotplugevent { attribute string action; // "add", "remove" attribute string path; // platform specific device path }; callback usbhotplugeventcallback = void (usbhotplugevent event); interface usbhotplug { void addeventlistener(string type, usbhotplugeventcallback callback); void removeeventlistener(string type, usbhotplugeventcallback callback); }; event creation to create a usbhotplug event, load the @brightsign/usbhotplug module using the require() method let usbhotplugclass = require("@brightsign/usbhotplug"); let usbhotplug = new usbhotplugclass(); usbhotplug use this interface to configure a usbhotplug event usbhotplugevent this event is raised when the hotplug status changes use the addeventlistener() method to listen for this event, or the removeeventlistener() method to remove an event listener usbhotplugevent properties action string string indicates whether a usb device has been added or removed path string string the path is an arbitrary string which varies between models and should not be parsed it may be useful for diagnostics the path will be the same for add and remove events for a particular usb device use @brightsign/deviceinfo getusbbustopology() to examine attached devices these events are hints that the topology has changed example let usbhotplugclass = require("@brightsign/usbhotplug"); let usbhotplug = new usbhotplugclass(); function onusbhotplugevent(event) { if (event action == 'add') { console log('new device at' + event path) } else if (event action == 'remove') { console log('device removed from' + event path) } } usbhotplug addeventlistener("usbhotplugevent", onusbhotplugevent);