Class CrateDigger
- java.lang.Object
-
- org.deepsymmetry.beatlink.data.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
VirtualCdjis forced to use a non-standard player number.To take advantage of these capabilities, simply call the
start()method and then use theMetadataFinderas you would have without this class.- Since:
- 0.5.0
- Author:
- James Elliott
-
-
Field Summary
Fields Modifier and Type Field Description FiledownloadDirectoryThe folder into which database exports and track analysis files will be downloaded.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDatabaseListener(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.org.deepsymmetry.cratedigger.DatabasefindDatabase(DataReference reference)Find the database we have downloaded and parsed that can provide information about the supplied data reference, if any.org.deepsymmetry.cratedigger.DatabasefindDatabase(SlotReference slot)Find the database we have downloaded and parsed that can provide information about the supplied slot reference, if any.Set<DatabaseListener>getDatabaseListeners()static CrateDiggergetInstance()Get the singleton instance of this class.intgetRetryLimit()Check how many times we will try to download a file from a player before giving up.static StringhumanReadableByteCount(long bytes, boolean si)Format a number of bytes in a human-centric format.booleanisRunning()Check whether we are currently running.voidremoveDatabaseListener(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.voidsetRetryLimit(int limit)Set how many times we will try to download a file from a player before giving up.voidstart()Start finding track metadata for all active players using the NFS server on the players to pull the exported database and track analysis files.voidstop()Stop finding track metadata for all active players.StringtoString()
-
-
-
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 bytessi- {code @true} if should use SI interpretation where k=1000- Returns:
- the nicely readable summary string
-
findDatabase
public org.deepsymmetry.cratedigger.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 org.deepsymmetry.cratedigger.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 ExceptionStart finding track metadata for all active players using the NFS server on the players to pull the exported database and track analysis files. Starts theMetadataFinderif 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. Iflistenerisnullor 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. Iflistenerisnullor 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
public Set<DatabaseListener> getDatabaseListeners()
-
-