3 import interfaces
.DJInterface
;
4 import interfaces
.PlaybackControl
;
5 import interfaces
.PlaybackStatus
;
6 import interfaces
.Track
;
7 import interfaces
.VolumeControl
;
8 import interfaces
.collection
.Collection
;
10 import java
.util
.HashSet
;
14 public class DJ
implements DJInterface
, PlaybackStatus
{
16 private final String name
;
19 private final Library library
;
20 private final interfaces
.Player player
;
21 private final interfaces
.PlaybackQueue queue
;
22 private final interfaces
.PlaybackControl control
;
23 private final interfaces
.VolumeControl volume
;
25 private final Set
<Collection
<?
extends Track
>> collections
;
27 public DJ(String name
) {
32 collections
= new HashSet
<Collection
<?
extends Track
>>();
34 library
= new Library("All Songs");
35 queue
= new PlaybackQueue(library
);
36 library
.addCollection(queue
.queue());
37 library
.addCollection(queue
.shuffle());
38 library
.addCollection(queue
.recent());
40 player
= new Player();
41 control
= new PlaybackController(player
, queue
);
42 volume
= new music
.VolumeControl();
49 public String
name() {
53 public Track
current() {
54 return queue
.current();
57 public int position() {
58 return queue
.position();
61 public int elapsedTime() {
62 return player
.elapsed();
65 public byte[] getAlbumArt() {
66 return player
.getAlbumArt();
69 public byte[] getCurrentSong() {
70 return player
.getCurrentSong();
73 public Collection
<?
extends Track
> playlist() {
74 return queue
.playlist();
78 return player
.status();
81 public PlaybackControl
playbackControl() {
85 public PlaybackStatus
playbackStatus() {
89 public VolumeControl
volume() {
93 public interfaces
.Library
<?
extends Track
> library() {
97 public Iterable
<Collection
<?
extends Track
>> collections() {
101 public boolean addCollection(Collection
<?
extends Track
> collection
) {
102 return collections
.add(collection
);
105 public boolean removeCollection(Collection
<?
extends Track
> collection
) {
106 return collections
.remove(collection
);