private WaveformPreview requestPreviewInternal ( final DataReference trackReference , final boolean failIfPassive ) { // First check if we are using cached data for this slot MetadataCache cache = MetadataFinder . getInstance ( ) . getMetadataCache ( SlotReference . getSlotReference ( trackReference ) ) ; if ( cache != null ) { return cache . getWaveformPreview ( null , trackReference ) ; } // Then see if any registered metadata providers can offer it for us. final MediaDetails sourceDetails = MetadataFinder . getInstance ( ) . getMediaDetailsFor ( trackReference . getSlotReference ( ) ) ; if ( sourceDetails != null ) { final WaveformPreview provided = MetadataFinder . getInstance ( ) . allMetadataProviders . getWaveformPreview ( sourceDetails , trackReference ) ; if ( provided != null ) { return provided ; } } // At this point, unless we are allowed to actively request the data, we are done. We can always actively // request tracks from rekordbox. if ( MetadataFinder . getInstance ( ) . isPassive ( ) && failIfPassive && trackReference . slot != CdjStatus . TrackSourceSlot . COLLECTION ) { return null ; } // We have to actually request the preview using the dbserver protocol. ConnectionManager . ClientTask < WaveformPreview > task = new ConnectionManager . ClientTask < WaveformPreview > ( ) { @ Override public WaveformPreview useClient ( Client client ) throws Exception { return getWaveformPreview ( trackReference . rekordboxId , SlotReference . getSlotReference ( trackReference ) , client ) ; } } ; try { return ConnectionManager . getInstance ( ) . invokeWithClientSession ( trackReference . player , task , "requesting waveform preview" ) ; } catch ( Exception e ) { logger . error ( "Problem requesting waveform preview, returning null" , e ) ; } return null ; }
Ask the specified player for the waveform preview in the specified slot with the specified rekordbox ID using cached media instead if it is available and possibly giving up if we are in passive mode .