Player APIs (BrightScript & Ja...
...
Object Reference
Hashing and Storage Objects

roStorageHotplug

9min
this object provides rostorageattached messages when storage devices appear and rostoragedetached messages when storage devices disappear an rostorageattached event is not delivered until the filesystem is mounted the javascript equivalent is node js fs watch() there is currently no way to poll for media object creation the rostoragehotplug object is created with no parameters createobject("rostoragehotplug") ifstoragehotplug getstorages() as object returns an ordered array of strings where each string is a drive specifier where the os will look for an autorun script for example \[ "usb1 /", "sd /", "sd2 /", "ssd /" ] note that note all drive specifiers may be present or even possibly present on the particular player getstoragestatus(drive as string) as roassociativearray returns the current status of a storage device ("sd ", "ssd ", "usb "), even if it is not mounted this method returns an associative array containing the following key value type description present boolean indicates whether the specified device is present mounted boolean indicates whether the specified device is mounted corrupt boolean indicates whether the specified device is believed to be corrupt checking boolean indicates whether the specified device is currently being checked the results of the getstoragestatus() method are unreliable when called with a "usbn " parameter, where "n" is a positive integer indicating a usb storage device when multiple usb devices are connected to the player example status = createobject("rostoragehotplug") getstoragestatus("ssd ") if not status mounted and not status checking and status present then ' should ask for confirmation here formatdrive("ssd ") end if iffailurereason getfailurereason() as string returns additional diagnostic information if a method returns false ifuserdata setuserdata(user data as object) sets the user data that will be returned when events are raised getuserdata() as object returns the user data that has previously been set via setuserdata() it will return invalid if no data has been set ifmessageport setport(port as romessageport) posts messages of type rostorageattached and rostoragedetached to the attached message port in order to avoid race conditions at startup, you should check for any storage devices that might have existed prior to the message port being set we recommend doing this after the object is created and the message port is set, but before instructing the script to wait for any events example sub main() mp = createobject("romessageport") sh = createobject("rostoragehotplug") gpio = createobject("rocontrolport", "brightsign") sh setport(mp) gpio setport(mp) finished = false while not finished ev = mp waitmessage(0) if type(ev) = "rocontroldown" finished = true else if type(ev) = "rostorageattached" print "attached "; ev getstring() else if type(ev) = "rostoragedetached" print "detached "; ev getstring() else print type(ev) stop end if end while end sub