Translate M4L patch to javascript - retrieve track number

    Feb 15 2014 | 8:37 pm
    I need to get the value of which track number the device is on in javascript. I found the example below and it works fine but I need to do the same inside javascript. I have tested a few ways but I can't figure out how to translate on my own. Please advise if you know:)

    • Feb 16 2014 | 9:01 am
      If you have the JavaScript device object it has an attribute "unquotedpath" which you can split to get the track number:
      var parts = device.unquotedpath.split (' '); var trackNo = Number (parts[2]);
      Example to get the device: var device = new LiveAPI ('live_set view selected_track view selected_device');
      If you just have a device ID, you can do:
      var api = new LiveAPI (); = Number (deviceID); var parts = apiunquotedpath.split (' ');
    • Feb 16 2014 | 10:54 am
      Thank you for the advise but I still did not get it to work. How can I retrieve the deviceID?
    • Feb 17 2014 | 12:15 pm
      This should do it:
      var api = new LiveAPI ('this_device'); var parts = api.unquotedpath.split (' '); var trackNo = Number (parts[2]);
    • Feb 17 2014 | 7:39 pm
      Brillian:) Thanks!
    • Feb 26 2014 | 10:48 am
      Hey Moss,
      How did you figure out that "unquotedpath" was even an available attribute? If I could just find documentation on what methods/attributes are available via LiveAPI, I could use it!