Browse Source

Play functions code added

feature-pr-USB-PlayTest
sahar 3 years ago
parent
commit
82124265f1
  1. 65
      src/main/java/device/usbPlayer/UsbPlayer.java

65
src/main/java/device/usbPlayer/UsbPlayer.java

@ -57,15 +57,35 @@ public class UsbPlayer implements Device {
return Lautstaerke;
}
@Override
public void louder() {
if(Lautstaerke < 100) {
Lautstaerke += 1;
//*********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 {
Lautstaerke = 100;
flag = false;
break;
}
}
//*********setters und getters********
return flag;
}
//**********search method*************
@Override
public void quieter() {
if(Lautstaerke > 0) {
@ -75,6 +95,15 @@ public class UsbPlayer implements Device {
}
}
@Override
public void louder() {
if(Lautstaerke < 100) {
Lautstaerke += 1;
} else {
Lautstaerke = 100;
}
}
@Override
public int getVolume() {
return 0;
@ -108,7 +137,29 @@ public class UsbPlayer implements Device {
@Override
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;
}
}
Loading…
Cancel
Save