Skip to content

Commit cff9b5f

Browse files
committed
0.7.1
1 parent 45d43df commit cff9b5f

File tree

7 files changed

+104
-103
lines changed

7 files changed

+104
-103
lines changed

.idea/workspace.xml

Lines changed: 81 additions & 92 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Music player library in pure Java.
6969
# 0.6.1 Beta
7070
## Se añade funcion para agregar más musica al reproductor
7171

72-
## 0.7
72+
## 0.7 Release
7373
## Se logra obtener duracion de archivos de audio para todos los formatos disponibles
7474
## Se añade opcion para obtener la caratula de un archivo de audio cualquiera
75+
## 0.7.1 Release
76+
## Se corrige el error que se produce al momento de dirigirse a una carpeta sin canciones

bin/OrangePlayer.jar

-10 Bytes
Binary file not shown.
73 Bytes
Binary file not shown.
-90 Bytes
Binary file not shown.

src/org/orangeplayer/audio/Player.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Player extends Thread implements PlayerControls {
2323
private int trackIndex;
2424
private float currentVolume;
2525
private boolean on;
26+
private boolean hasSounds;
2627

2728
public static float DEFAULT_VOLUME = 80.0f;
2829

@@ -51,6 +52,7 @@ public Player() {
5152
trackIndex = 0;
5253
currentVolume = DEFAULT_VOLUME;
5354
on = false;
55+
hasSounds = false;
5456
setName("ThreadPlayer "+getId());
5557
}
5658
public Player(File rootFolder) throws FileNotFoundException {
@@ -59,13 +61,14 @@ public Player(File rootFolder) throws FileNotFoundException {
5961
listListeners = new ArrayList<>();
6062
trackIndex = 0;
6163
currentVolume = DEFAULT_VOLUME;
64+
on = false;
65+
hasSounds = false;
6266
if (!rootFolder.exists())
6367
throw new FileNotFoundException();
6468
else {
6569
loadTracks(rootFolder);
6670
sortTracks();
6771
}
68-
on = false;
6972
setName("ThreadPlayer "+getId());
7073
}
7174

@@ -227,14 +230,20 @@ private void waitForSongs() {
227230
}
228231

229232
void loadNextTrack() {
233+
// Se debe verificar que no es un archivo de audio porque
234+
// cuando solo hay archivos que no son audio se lanza un
235+
// nullpointerexception
236+
230237
waitForSongs();
231238
Track cur = current;
232239
current = getNextTrack();
233240
finishTrack(cur);
234-
startNewTrackThread();
241+
if (current != null) {
242+
startNewTrackThread();
243+
System.out.println("Song: "+trackIndex);
244+
System.out.println(current.getInfoSong());
245+
}
235246
loadListenerMethod("onSongChange", current);
236-
System.out.println("Song: "+trackIndex);
237-
System.out.println(current.getInfoSong());
238247
}
239248

240249
// Test
@@ -278,7 +287,7 @@ public Track getCurrent() {
278287
return current;
279288
}
280289

281-
public SourceDataLine getTrackLine() {
290+
public synchronized SourceDataLine getTrackLine() {
282291
if (current == null)
283292
System.out.println("Current is null");
284293
else {

src/org/orangeplayer/ontesting/TestPlayer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
public class TestPlayer {
1414
public static void main(String[] args) throws IOException {
1515
boolean hasArgs = args != null && args.length > 0;
16-
String fPath = hasArgs ? args[0] : "/home/martin/AudioTesting/music/";
16+
String fPath = hasArgs ? args[0] : "/home/martin/AudioTesting/audio/nosound";
17+
18+
// Ver validacion de archivos de audio y que hacer cuando
19+
// la carpeta esta vacia al cargar la carpeta para evitar
20+
// un buble infinito cuando se lee una carpeta sin archivos de audio
1721

1822
//Player.newInstance(fPath);
1923
//Player player = Player.getPlayer();
@@ -23,9 +27,6 @@ public static void main(String[] args) throws IOException {
2327
System.out.println("Sounds total: "+player.getSongsCount());
2428

2529
Scanner scan = new Scanner(System.in);
26-
// /home/martin/AudioTesting/music/Alejandro Silva/1 - 1999/AlbumArtSmall.jpg
27-
// /home/martin/AudioTesting/music/NSYNC/NSYNC - No Strings Attached (2000)/ReadMe.txt
28-
2930
SourceDataLine trackLine = player.getTrackLine();
3031

3132
char c;
@@ -43,7 +44,7 @@ public static void main(String[] args) throws IOException {
4344
player.jumpTrack(Integer.parseInt(line.substring(2)));
4445
player.playNext();
4546
System.err.println("Antes de trackLine");
46-
trackLine = player.getCurrent().getTrackLine().getDriver();
47+
trackLine = player.getTrackLine();
4748
System.err.println("Antes de controls");
4849
System.out.println("Controls: "+Arrays.toString(trackLine.getControls()));
4950
Control pan = trackLine.getControl(FloatControl.Type.PAN);

0 commit comments

Comments
 (0)