Ignore rules for git users
[stereo.git] / MemphisDJ / src / music / DJ.java
blob7c43ce2cca4706730590a2a7a6b125ab3dee5b38
1 package music;
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;
11 import java.util.Set;
14 public class DJ implements DJInterface, PlaybackStatus {
16 private final String name;
17 private final int id;
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) {
29 this.name = name;
30 this.id = 1;
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();
45 public int id() {
46 return id;
49 public String name() {
50 return 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();
77 public byte state() {
78 return player.status();
81 public PlaybackControl playbackControl() {
82 return control;
85 public PlaybackStatus playbackStatus() {
86 return this;
89 public VolumeControl volume() {
90 return volume;
93 public interfaces.Library<? extends Track> library() {
94 return library;
97 public Iterable<Collection<? extends Track>> collections() {
98 return 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);