public class WaveformFinder extends LifecycleParticipant
Watches for new metadata to become available for tracks loaded on players, and queries the appropriate player for track waveforms when that happens. Can be configured to load only the small waveform previews, or both those and the full scrollable waveform details.
Maintains a hot cache of waveforms for any track currently loaded in a player, either on the main playback deck, or as a hot cue, since those tracks could start playing instantly.
Implicitly honors the active/passive setting of the MetadataFinder
(see MetadataFinder.setPassive(boolean)), because art is loaded in response to metadata updates.
| Modifier and Type | Method and Description |
|---|---|
void |
addWaveformListener(WaveformListener listener)
Adds the specified waveform listener to receive updates when the waveform information for a player changes.
|
WaveformDetail |
getCachedWaveformDetail(ZipFile cache,
DataReference dataReference)
Look up waveform detail in a metadata cache.
|
WaveformPreview |
getCachedWaveformPreview(ZipFile cache,
DataReference dataReference)
Look up a waveform preview in a metadata cache.
|
static WaveformFinder |
getInstance()
Get the singleton instance of this class.
|
WaveformDetail |
getLatestDetailFor(DeviceUpdate update)
Look up the waveform detail we have for a given player, identified by a status update received from that player.
|
WaveformDetail |
getLatestDetailFor(int player)
Look up the waveform detail we have for the track loaded in the main deck of a given player number.
|
WaveformPreview |
getLatestPreviewFor(DeviceUpdate update)
Look up the waveform preview we have for a given player, identified by a status update received from that player.
|
WaveformPreview |
getLatestPreviewFor(int player)
Look up the waveform preview we have for the track loaded in the main deck of a given player number.
|
Map<DeckReference,WaveformDetail> |
getLoadedDetails()
Get the waveform details available for all tracks currently loaded in any player, either on the play deck, or
in a hot cue.
|
Map<DeckReference,WaveformPreview> |
getLoadedPreviews()
Get the waveform previews available for all tracks currently loaded in any player, either on the play deck, or
in a hot cue.
|
Set<WaveformListener> |
getWaveformListeners()
Get the set of currently-registered waveform listeners.
|
boolean |
isFindingDetails()
Check whether we are retrieving the waveform details in addition to the waveform previews.
|
boolean |
isRunning()
Check whether we are currently running.
|
void |
removeWaveformListener(WaveformListener listener)
Removes the specified waveform listener so that it no longer receives updates when the
waveform information for a player changes.
|
WaveformDetail |
requestWaveformDetailFrom(DataReference dataReference)
Ask the specified player for the specified waveform detail from the specified media slot, first checking if we
have a cached copy.
|
WaveformPreview |
requestWaveformPreviewFrom(DataReference dataReference)
Ask the specified player for the specified waveform preview from the specified media slot, first checking if we
have a cached copy.
|
void |
setFindDetails(boolean findDetails)
Set whether we should retrieve the waveform details in addition to the waveform previews.
|
void |
start()
Start finding waveforms for all active players.
|
void |
stop()
Stop finding waveforms for all active players.
|
String |
toString() |
addLifecycleListener, deliverLifecycleAnnouncement, ensureRunning, getLifecycleListeners, removeLifecycleListenerpublic final void setFindDetails(boolean findDetails)
findDetails - if true, both types of waveform will be retrieved, if false only previews
will be retrievedpublic final boolean isFindingDetails()
true if both types of waveform are being retrieved, false if only previews
are being retrievedpublic boolean isRunning()
MetadataFinder is in passive mode, we will
automatically request waveforms from the appropriate player when a new track is loaded that is not found
in the hot cache or an attached metadata cache file.isRunning in class LifecycleParticipantMetadataFinder.isPassive()public Map<DeckReference,WaveformPreview> getLoadedPreviews()
IllegalStateException - if the WaveformFinder is not runningpublic Map<DeckReference,WaveformDetail> getLoadedDetails()
IllegalStateException - if the WaveformFinder is not running or requesting waveform detailspublic WaveformPreview getLatestPreviewFor(int player)
player - the device number whose waveform preview for the playing track is desiredIllegalStateException - if the WaveformFinder is not runningpublic WaveformPreview getLatestPreviewFor(DeviceUpdate update)
update - a status update from the player for which a waveform preview is desiredIllegalStateException - if the WaveformFinder is not runningpublic WaveformDetail getLatestDetailFor(int player)
player - the device number whose waveform detail for the playing track is desiredIllegalStateException - if the WaveformFinder is not runningpublic WaveformDetail getLatestDetailFor(DeviceUpdate update)
update - a status update from the player for which waveform detail is desiredIllegalStateException - if the WaveformFinder is not runningpublic WaveformPreview requestWaveformPreviewFrom(DataReference dataReference)
dataReference - uniquely identifies the desired waveform previewnullIllegalStateException - if the WaveformFinder is not runningpublic WaveformPreview getCachedWaveformPreview(ZipFile cache, DataReference dataReference)
cache - the appropriate metadata cache filedataReference - the unique database specification of the desired waveform previewnullpublic WaveformDetail requestWaveformDetailFrom(DataReference dataReference)
dataReference - uniquely identifies the desired waveform detailnullIllegalStateException - if the WaveformFinder is not runningpublic WaveformDetail getCachedWaveformDetail(ZipFile cache, DataReference dataReference)
cache - the appropriate metadata cache filedataReference - the unique database specification of the desired waveform detailnullpublic void addWaveformListener(WaveformListener listener)
Adds the specified waveform listener to receive updates when the waveform information for a player changes.
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.
listener - the album art update listener to addpublic void removeWaveformListener(WaveformListener listener)
listener is null or not present
in the set of registered listeners, no exception is thrown and no action is performed.listener - the waveform listener to removepublic Set<WaveformListener> getWaveformListeners()
public void start()
throws Exception
Start finding waveforms for all active players. Starts the MetadataFinder if it is not already
running, because we need it to send us metadata updates to notice when new tracks are loaded. This in turn
starts the DeviceFinder, so we can keep track of the comings and goings of players themselves.
We also start the ConnectionManager in order to make queries to obtain waveforms.
Exception - if there is a problem starting the required componentspublic void stop()
public static WaveformFinder getInstance()
Copyright © 2016–2018 Deep Symmetry, LLC. All rights reserved.