|
@ -2,9 +2,50 @@ package device.usbPlayer; |
|
|
|
|
|
|
|
|
import device.Device; |
|
|
import device.Device; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
public class UsbPlayer implements Device { |
|
|
public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
private int Lautstaerke = 0; |
|
|
|
|
|
|
|
|
private ArrayList<String> Playlist = new ArrayList<String>(); |
|
|
|
|
|
private String playTrack = ""; |
|
|
|
|
|
private Boolean isConnected; |
|
|
|
|
|
private Boolean isDefect; |
|
|
|
|
|
int Lautstaerke = 0; |
|
|
|
|
|
|
|
|
|
|
|
//*********setters und getters******** |
|
|
|
|
|
public ArrayList<String> getPlaylist() { |
|
|
|
|
|
return Playlist; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setPlaylist(ArrayList<String> playlist) { |
|
|
|
|
|
Playlist = playlist; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Boolean getDefect() { |
|
|
|
|
|
return isDefect; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setDefect(Boolean defect) { |
|
|
|
|
|
isDefect = defect; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Boolean getConnected() { |
|
|
|
|
|
return isConnected; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setConnected(Boolean connected) { |
|
|
|
|
|
isConnected = connected; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getPlayTrack() { |
|
|
|
|
|
return playTrack; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setPlayTrack(String playTrack) { |
|
|
|
|
|
this.playTrack = playTrack; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setLautstaerke(int ls) { |
|
|
public void setLautstaerke(int ls) { |
|
|
if (ls <= 100) { |
|
|
if (ls <= 100) { |
|
@ -16,15 +57,35 @@ public class UsbPlayer implements Device { |
|
|
return Lautstaerke; |
|
|
return Lautstaerke; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void louder() { |
|
|
|
|
|
if(Lautstaerke < 100) { |
|
|
|
|
|
Lautstaerke += 1; |
|
|
|
|
|
} else { |
|
|
|
|
|
Lautstaerke = 100; |
|
|
|
|
|
|
|
|
//*********constructure******** |
|
|
|
|
|
public UsbPlayer() { |
|
|
|
|
|
super(); |
|
|
|
|
|
isDefect = false; |
|
|
|
|
|
isConnected = true; |
|
|
|
|
|
Playlist.add("Musik 01.mp3"); |
|
|
|
|
|
Playlist.add("Musik 02.mp3"); |
|
|
|
|
|
Playlist.add("Musik 03.mp3"); |
|
|
|
|
|
playTrack = Playlist.get(0); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
//**********search method************* |
|
|
|
|
|
private boolean isAllAudio() { |
|
|
|
|
|
|
|
|
|
|
|
String song = ""; |
|
|
|
|
|
boolean flag = true; |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < Playlist.size(); i++) { |
|
|
|
|
|
song = Playlist.get(i).substring(Playlist.get(i).length() - 4); |
|
|
|
|
|
if (song.equals(".mp3") | song.equals(".mp4") | song.equals(".wav")) { |
|
|
|
|
|
flag = true; |
|
|
|
|
|
} else { |
|
|
|
|
|
flag = false; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return flag; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//**********search method************* |
|
|
@Override |
|
|
@Override |
|
|
public void quieter() { |
|
|
public void quieter() { |
|
|
if(Lautstaerke > 0) { |
|
|
if(Lautstaerke > 0) { |
|
@ -34,6 +95,15 @@ public class UsbPlayer implements Device { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void louder() { |
|
|
|
|
|
if(Lautstaerke < 100) { |
|
|
|
|
|
Lautstaerke += 1; |
|
|
|
|
|
} else { |
|
|
|
|
|
Lautstaerke = 100; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public int getVolume() { |
|
|
public int getVolume() { |
|
|
return 0; |
|
|
return 0; |
|
@ -67,7 +137,29 @@ public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String play() { |
|
|
public String play() { |
|
|
return null; |
|
|
|
|
|
|
|
|
String result = "USB : "; |
|
|
|
|
|
if (isConnected == true) { |
|
|
|
|
|
result += "connected,"; |
|
|
|
|
|
if (isDefect == false) { |
|
|
|
|
|
result += "working"; |
|
|
|
|
|
if (this.Playlist.size() != 0) { |
|
|
|
|
|
result += ",have a list"; |
|
|
|
|
|
if (this.isAllAudio()) { |
|
|
|
|
|
result += ",Audio"; |
|
|
|
|
|
if (!playTrack.equals("")) |
|
|
|
|
|
result += ",point to a track."; |
|
|
|
|
|
else |
|
|
|
|
|
result += ",doesn't point to a track."; |
|
|
|
|
|
} else { |
|
|
|
|
|
result += ",not Audio."; |
|
|
|
|
|
} |
|
|
|
|
|
} else result += ",have no list."; |
|
|
|
|
|
} else { |
|
|
|
|
|
result += "not working."; |
|
|
|
|
|
} |
|
|
|
|
|
} else result = "not connected."; |
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |