Class CrateDigger


  • 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

        public final File downloadDirectory
        The folder into which database exports and track analysis files will be downloaded.
    • Method Detail

      • getRetryLimit

        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

        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

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

        public static String humanReadableByteCount​(long bytes,
                                                    boolean si)
        Format a number of bytes in a human-centric format. From https://stackoverflow.com/a/3758880/802383
        Parameters:
        bytes - the number of bytes
        si - {code @true} if should use SI interpretation where k=1000
        Returns:
        the nicely readable summary string
      • findDatabase

        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

        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

        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

        public void stop()
        Stop finding track metadata for all active players.
      • getInstance

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

        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

        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