|
@ -6,13 +6,14 @@ import java.util.ArrayList; |
|
|
|
|
|
|
|
|
public class UsbPlayer implements Device { |
|
|
public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArrayList<String> Playlist = new ArrayList<String>(); |
|
|
private ArrayList<String> Playlist = new ArrayList<String>(); |
|
|
private String playTrack = ""; |
|
|
private String playTrack = ""; |
|
|
private Boolean isConnected; |
|
|
private Boolean isConnected; |
|
|
private Boolean isDefect; |
|
|
private Boolean isDefect; |
|
|
int Lautstaerke = 0; |
|
|
int Lautstaerke = 0; |
|
|
|
|
|
public USB_Stick USBDrive = new USB_Stick(); |
|
|
|
|
|
|
|
|
//*********setters und getters******** |
|
|
|
|
|
public ArrayList<String> getPlaylist() { |
|
|
public ArrayList<String> getPlaylist() { |
|
|
return Playlist; |
|
|
return Playlist; |
|
|
} |
|
|
} |
|
@ -43,9 +44,9 @@ public class UsbPlayer implements Device { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setPlayTrack(String playTrack) { |
|
|
public void setPlayTrack(String playTrack) { |
|
|
if(this.findSong(playTrack) != -1){ |
|
|
|
|
|
this.playTrack = playTrack;} |
|
|
|
|
|
else System.out.println("The Song does not exist in the Albume"); |
|
|
|
|
|
|
|
|
if (this.findSong(playTrack) != -1) { |
|
|
|
|
|
this.playTrack = playTrack; |
|
|
|
|
|
} else System.out.println("The Song does not exist in the Albume"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -64,12 +65,15 @@ public class UsbPlayer implements Device { |
|
|
super(); |
|
|
super(); |
|
|
isDefect = false; |
|
|
isDefect = false; |
|
|
isConnected = true; |
|
|
isConnected = true; |
|
|
Playlist.add("Musik 01.mp3"); |
|
|
|
|
|
|
|
|
/*Playlist.add("Musik 01.mp3"); |
|
|
Playlist.add("Musik 02.mp3"); |
|
|
Playlist.add("Musik 02.mp3"); |
|
|
Playlist.add("Musik 03.mp3"); |
|
|
Playlist.add("Musik 03.mp3"); |
|
|
|
|
|
playTrack = Playlist.get(0);*/ |
|
|
|
|
|
Playlist = USBDrive.getAlbum(); |
|
|
playTrack = Playlist.get(0); |
|
|
playTrack = Playlist.get(0); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//**********search method************* |
|
|
//**********search method************* |
|
|
public boolean isAllAudio() { |
|
|
public boolean isAllAudio() { |
|
|
|
|
|
|
|
@ -78,7 +82,7 @@ public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
for (int i = 0; i < Playlist.size(); i++) { |
|
|
for (int i = 0; i < Playlist.size(); i++) { |
|
|
song = Playlist.get(i).substring(Playlist.get(i).length() - 4); |
|
|
song = Playlist.get(i).substring(Playlist.get(i).length() - 4); |
|
|
if (song.equals(".mp3") | song.equals(".mp4")| song.equals(".m4a")| song.equals(".wav")| song.equals(".wma")| song.equals(".aac") ) { |
|
|
|
|
|
|
|
|
if (song.equals(".mp3") | song.equals(".mp4") | song.equals(".m4a") | song.equals(".wav") | song.equals(".wma") | song.equals(".aac")) { |
|
|
flag = true; |
|
|
flag = true; |
|
|
} else { |
|
|
} else { |
|
|
flag = false; |
|
|
flag = false; |
|
@ -87,10 +91,12 @@ public class UsbPlayer implements Device { |
|
|
} |
|
|
} |
|
|
return flag; |
|
|
return flag; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//**********search method************* |
|
|
//**********search method************* |
|
|
@Override |
|
|
@Override |
|
|
public void quieter() { |
|
|
public void quieter() { |
|
|
if(Lautstaerke > 0) { |
|
|
|
|
|
|
|
|
if (Lautstaerke > 0) { |
|
|
Lautstaerke -= 1; |
|
|
Lautstaerke -= 1; |
|
|
} else { |
|
|
} else { |
|
|
Lautstaerke = 0; |
|
|
Lautstaerke = 0; |
|
@ -99,21 +105,21 @@ public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void louder() { |
|
|
public void louder() { |
|
|
if(Lautstaerke < 100) { |
|
|
|
|
|
|
|
|
if (Lautstaerke < 100) { |
|
|
Lautstaerke += 1; |
|
|
Lautstaerke += 1; |
|
|
} else { |
|
|
} else { |
|
|
Lautstaerke = 100; |
|
|
Lautstaerke = 100; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void Louder_10(){ |
|
|
|
|
|
|
|
|
public void Louder_10() { |
|
|
Lautstaerke += 10; |
|
|
Lautstaerke += 10; |
|
|
if (Lautstaerke > 100) { |
|
|
if (Lautstaerke > 100) { |
|
|
Lautstaerke = 100; |
|
|
Lautstaerke = 100; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void quieter_10(){ |
|
|
|
|
|
|
|
|
public void quieter_10() { |
|
|
Lautstaerke -= 10; |
|
|
Lautstaerke -= 10; |
|
|
if (Lautstaerke < 0) { |
|
|
if (Lautstaerke < 0) { |
|
|
Lautstaerke = 0; |
|
|
Lautstaerke = 0; |
|
@ -190,32 +196,31 @@ public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public int findSong(String songName){ |
|
|
|
|
|
|
|
|
public int findSong(String songName) { |
|
|
|
|
|
|
|
|
int songIndex =-1, index=-1; |
|
|
|
|
|
|
|
|
int songIndex = -1, index = -1; |
|
|
String song; |
|
|
String song; |
|
|
|
|
|
|
|
|
for (int j = 0; j < getPlaylist().size(); j++) { |
|
|
for (int j = 0; j < getPlaylist().size(); j++) { |
|
|
|
|
|
|
|
|
song = getPlaylist().get(j); |
|
|
song = getPlaylist().get(j); |
|
|
songIndex=song.toLowerCase().indexOf(songName.toLowerCase()); |
|
|
|
|
|
|
|
|
songIndex = song.toLowerCase().indexOf(songName.toLowerCase()); |
|
|
|
|
|
|
|
|
if (songIndex != -1) { |
|
|
if (songIndex != -1) { |
|
|
index = j; |
|
|
|
|
|
|
|
|
index = j; |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return index; |
|
|
return index; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public boolean GoTo(String songName){ |
|
|
|
|
|
if(findSong(songName) != -1){ |
|
|
|
|
|
|
|
|
public boolean GoTo(String songName) { |
|
|
|
|
|
if (findSong(songName) != -1) { |
|
|
playTrack = getPlaylist().get(findSong(songName));//songName; |
|
|
playTrack = getPlaylist().get(findSong(songName));//songName; |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
//playTrack = songName; |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
} else |
|
|
|
|
|
//playTrack = songName; |
|
|
|
|
|
return false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void GoToFirst() { |
|
|
public void GoToFirst() { |
|
@ -225,6 +230,6 @@ public class UsbPlayer implements Device { |
|
|
|
|
|
|
|
|
public void GoToLast() { |
|
|
public void GoToLast() { |
|
|
//go to the last Song |
|
|
//go to the last Song |
|
|
setPlayTrack(this.getPlaylist().get(this.getPlaylist().size()-1)); |
|
|
|
|
|
|
|
|
setPlayTrack(this.getPlaylist().get(this.getPlaylist().size() - 1)); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |