Class CrateDigger


  • @API(status=STABLE)
    public class CrateDigger
    extends Object

    Uses the Crate Digger library to provide an even more reliable source of track metadata, even when there are four players in use on the network and the VirtualCdj is forced to use a non-standard player number.

    To take advantage of these capabilities, simply call the start() method and then use the MetadataFinder as you would have without this class.

    Since:
    0.5.0
    Author:
    James Elliott
    • Field Detail

      • downloadDirectory

        @API(status=STABLE)
        public final File downloadDirectory
        The folder into which database exports and track analysis files will be downloaded.
    • Method Detail

      • getRetryLimit

        @API(status=STABLE)
        public int getRetryLimit()
        Check how many times we will try to download a file from a player before giving up.
        Returns:
        the maximum number of attempts we will make when a file download fails
      • setRetryLimit

        @API(status=STABLE)
        public void setRetryLimit​(int limit)
        Set how many times we will try to download a file from a player before giving up.
        Parameters:
        limit - the maximum number of attempts we will make when a file download fails
      • isRunning

        @API(status=STABLE)
        public boolean isRunning()
        Check whether we are currently running.
        Returns:
        true if track metadata is being fetched using NFS for all active players
      • humanReadableByteCount

        @API(status=STABLE)
        public static String humanReadableByteCount​(long bytes,
                                                    boolean si)
        Format a number of bytes in a human-centric format. From Stack Overflow
        Parameters:
        bytes - the number of bytes
        si - {code @true} if we should use SI interpretation where k=1000
        Returns:
        the nicely readable summary string
      • findDatabase

        @API(status=STABLE)
        public Database findDatabase​(DataReference reference)
        Find the database we have downloaded and parsed that can provide information about the supplied data reference, if any.
        Parameters:
        reference - identifies the location from which data is desired
        Returns:
        the appropriate rekordbox extract to start from in finding that data, if we have one
      • findDatabase

        @API(status=STABLE)
        public Database findDatabase​(SlotReference slot)
        Find the database we have downloaded and parsed that can provide information about the supplied slot reference, if any.
        Parameters:
        slot - identifies the slot from which data is desired
        Returns:
        the appropriate rekordbox extract to start from in finding that data, if we have one
      • start

        @API(status=STABLE)
        public void start()
                   throws Exception
        Start finding track metadata for all active players using the NFS server on the players to pull the exported database and track analysis files. Starts the MetadataFinder if it is not already running, because we build on its features. This will transitively start many of the other Beat Link subsystems, and stopping any of them will stop us as well.
        Throws:
        Exception - if there is a problem starting the required components
      • stop

        @API(status=STABLE)
        public void stop()
        Stop finding track metadata for all active players.
      • getInstance

        @API(status=STABLE)
        public static CrateDigger getInstance()
        Get the singleton instance of this class.
        Returns:
        the only instance of this class which exists.
      • addDatabaseListener

        @API(status=STABLE)
        public void addDatabaseListener​(DatabaseListener listener)
        Adds the specified database listener to receive updates when a rekordbox database has been obtained for a media slot, or when the underlying media for a database has been unmounted, so it is no longer relevant. If listener is null or already present in the set of registered listeners, no exception is thrown and no action is performed.

        To reduce latency, updates are delivered to listeners directly on the thread that is receiving packets from the network, so if you want to interact with user interface objects in listener methods, you need to use javax.swing.SwingUtilities.invokeLater(Runnable) to do so on the Event Dispatch Thread.

        Even if you are not interacting with user interface objects, any code in the listener method must finish quickly, or it will add latency for other listeners, and updates will back up. If you want to perform lengthy processing of any sort, do so on another thread.

        Parameters:
        listener - the database update listener to add
      • removeDatabaseListener

        @API(status=STABLE)
        public void removeDatabaseListener​(DatabaseListener listener)
        Removes the specified database listener so that it no longer receives updates when there are changes to the available set of rekordbox databases. If listener is null or not present in the set of registered listeners, no exception is thrown and no action is performed.
        Parameters:
        listener - the database update listener to remove
      • getDatabaseListeners

        @API(status=STABLE)
        public Set<DatabaseListener> getDatabaseListeners()