TrackMetadata queryMetadata ( final DataReference track , final CdjStatus . TrackType trackType , final Client client ) throws IOException , InterruptedException , TimeoutException { // Send the metadata menu request if ( client . tryLockingForMenuOperations ( 20 , TimeUnit . SECONDS ) ) { try { final Message . KnownType requestType = ( trackType == CdjStatus . TrackType . REKORDBOX ) ? Message . KnownType . REKORDBOX_METADATA_REQ : Message . KnownType . UNANALYZED_METADATA_REQ ; final Message response = client . menuRequestTyped ( requestType , Message . MenuIdentifier . MAIN_MENU , track . slot , trackType , new NumberField ( track . rekordboxId ) ) ; final long count = response . getMenuResultsCount ( ) ; if ( count == Message . NO_MENU_RESULTS_AVAILABLE ) { return null ; } // Gather the cue list and all the metadata menu items final List < Message > items = client . renderMenuItems ( Message . MenuIdentifier . MAIN_MENU , track . slot , trackType , response ) ; final CueList cueList = getCueList ( track . rekordboxId , track . slot , client ) ; return new TrackMetadata ( track , trackType , items , cueList ) ; } finally { client . unlockForMenuOperations ( ) ; } } else { throw new TimeoutException ( "Unable to lock the player for menu operations" ) ; } }
Request metadata for a specific track ID given a dbserver connection to a player that has already been set up . Separated into its own method so it could be used multiple times with the same connection when gathering all track metadata .