-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.txt
100 lines (84 loc) · 2.92 KB
/
design.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Design document
available event listeners
* Device Announcement
* Beat
* Master
* Update <-- most information
* Media Details <-- callback when requesting
* Mount
* Signature
CdjScrobbler.SongModel
* properties:
which device <- CdjStatus.getTrackSourcePlayer()
has metadata? <- true after our media query has finished
song details <- set after ^
total played time <- updated with each received message
current state <- see below
last update timestamp <- timestamp of last CdjStatus received.
Needed for incrementing played time,
* methods
updatePlayTime()
CdjScrobbler.SongState
* states:
Started
Ignored
Cueing
Playing
PlayingPaused
Scrobbling
ScrobblingPaused
Stopped
Song Transitions
Started -> Ignored (happens when no metadata available)
Started -> Cueing
Ignored -> Stopped
Cueing -> Started
Cueing -> Playing <- raise a now playing (get metadata now)
Playing -> PlayingPaused
Playing -> Stopped
Playing -> Scrobbling
PlayingPaused -> Playing
PlayingPaused -> Stopped
Scrobbling -> ScrobblingPaused
Scrobbling -> Stopped <- raise a retire-scrobbling
ScrobblingPaused -> Scrobbling
ScrobblingPaused -> Stopped <- raise a retire-scrobbling
CdjScrobbler.UpdateListener
* methods
receive(DeviceUpdate update) https://deepsymmetry.org/beatlink/apidocs/org/deepsymmetry/beatlink/DeviceUpdateListener.html
* either a MixerStatus or a CdjStatus (which is what we're interested in)
* how do we use this to work out the play time of a track?
General:
* receive things which send us to stopped (such as change of track or eject)
isAtEnd() true
isTrackLoaded() false
* receive things which increment play time by (timestamp - previous timestamp) x Util.pitchToPercentage(getPitch()), but only if isPlayingForward()
* if play time > 30s
transition Cueing -> Playing
* if scrobble point known && play time > scrobble point
transition Playing -> Scrobbled
CdjScrobbler
* songscrobbler Map<int, CdjScrobblerSongModel>
start a metadatafinder (see https://github.com/Deep-Symmetry/beat-link/#media-details)
* receive(DeviceUpdate)
if isLinkMediaAvailable()
send to the right cdjSongScrobbler
add returned event (if any) to the queue of events to deal with TODO
e.g now playing, retire scrobbling
if the song scrobbler is now Stopped:
recreate song scrobbler
thread design
* event update thread will notify UpdateListener on the event processing thread
* this must then put song events on to the queue quickly and .notify the queue processor
Classes:
* CdjScrobbler.Application
* CdjScrobbler.UpdateListener
* CdjScrobbler.SongModel
* CdjScrobbler.SongState (enum)
* CdjScrobbler.QueueProcessor
* CdjScrobbler.SongEvent (abstract)
* CdjScrobbler.NowPlayingEvent
* CdjScrobbler.ScrobbleEvent
* CdjScrobbler.NowPlayingEventListener (interface)
* CdjScrobbler.ScrobbleEventListener (interface)
* CdjScrobbler.Scrobbler