private AlbumArt requestArtworkInternal ( final DataReference artReference , final CdjStatus . TrackType trackType , final boolean failIfPassive ) { // First check if we are using cached data for this slot. MetadataCache cache = MetadataFinder . getInstance ( ) . getMetadataCache ( SlotReference . getSlotReference ( artReference ) ) ; if ( cache != null ) { final AlbumArt result = cache . getAlbumArt ( null , artReference ) ; if ( result != null ) { artCache . put ( artReference , result ) ; } return result ; } // Then see if any registered metadata providers can offer it for us. final MediaDetails sourceDetails = MetadataFinder . getInstance ( ) . getMediaDetailsFor ( artReference . getSlotReference ( ) ) ; if ( sourceDetails != null ) { final AlbumArt provided = MetadataFinder . getInstance ( ) . allMetadataProviders . getAlbumArt ( sourceDetails , artReference ) ; 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 && artReference . slot != CdjStatus . TrackSourceSlot . COLLECTION ) { return null ; } // We have to actually request the art using the dbserver protocol. ConnectionManager . ClientTask < AlbumArt > task = new ConnectionManager . ClientTask < AlbumArt > ( ) { @ Override public AlbumArt useClient ( Client client ) throws Exception { return getArtwork ( artReference . rekordboxId , SlotReference . getSlotReference ( artReference ) , trackType , client ) ; } } ; try { AlbumArt artwork = ConnectionManager . getInstance ( ) . invokeWithClientSession ( artReference . player , task , "requesting artwork" ) ; if ( artwork != null ) { // Our cache file load or network request succeeded, so add to the level 2 cache. artCache . put ( artReference , artwork ) ; } return artwork ; } catch ( Exception e ) { logger . error ( "Problem requesting album art, returning null" , e ) ; } return null ; }
Ask the specified player for the album art 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 .