Skip to content

Commit e50245f

Browse files
authored
Merge pull request #33 from HelgeStenstrom/noPrinting
Remove printing to System.out
2 parents 4991e4a + bd5d246 commit e50245f

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public void play() throws StreamPlayerException {
583583
try {
584584
initLine();
585585
} catch (final LineUnavailableException ex) {
586-
throw new StreamPlayerException(StreamPlayerException.PlayerException.CAN_NOT_INIT_LINE, ex);
586+
throw new StreamPlayerException(PlayerException.CAN_NOT_INIT_LINE, ex);
587587
}
588588

589589
// Open the sourceDataLine
@@ -666,7 +666,7 @@ private void awaitTermination() {
666666
Thread.sleep(20);
667667
else
668668
break;
669-
System.out.println("StreamPlayer Future is not yet done...");
669+
logger.log(Level.INFO, "StreamPlayer Future is not yet done...");
670670
}
671671

672672
} catch (final InterruptedException ex) {
@@ -708,7 +708,7 @@ public long seekBytes(final long bytes) throws StreamPlayerException {
708708

709709
// Check if the requested bytes are more than totalBytes of Audio
710710
final long bytesLength = getTotalBytes();
711-
System.out.println("Bytes: " + bytes + " BytesLength: " + bytesLength);
711+
logger.log(Level.INFO, "Bytes: " + bytes + " BytesLength: " + bytesLength);
712712
if ((bytesLength <= 0) || (bytes >= bytesLength)) {
713713
generateEvent(Status.EOM, getEncodedStreamPosition(), null);
714714
return totalSkipped;
@@ -734,7 +734,7 @@ public long seekBytes(final long bytes) throws StreamPlayerException {
734734
logger.info("Skipped : " + totalSkipped + "/" + bytes);
735735
if (totalSkipped == -1)
736736
throw new StreamPlayerException(
737-
StreamPlayerException.PlayerException.SKIP_NOT_SUPPORTED);
737+
PlayerException.SKIP_NOT_SUPPORTED);
738738

739739
logger.info("Skeeping:" + totalSkipped);
740740
}
@@ -1281,7 +1281,7 @@ public void setBalance(final float fBalance) {
12811281
balanceControl.setValue(fBalance);
12821282
else
12831283
try {
1284-
throw new StreamPlayerException(StreamPlayerException.PlayerException.BALANCE_CONTROL_NOT_SUPPORTED);
1284+
throw new StreamPlayerException(PlayerException.BALANCE_CONTROL_NOT_SUPPORTED);
12851285
} catch (final StreamPlayerException ex) {
12861286
logger.log(Level.WARNING, ex.getMessage(), ex);
12871287
}
@@ -1387,4 +1387,7 @@ public boolean isSeeking() {
13871387
return status == Status.SEEKING;
13881388
}
13891389

1390+
Logger getLogger() {
1391+
return logger;
1392+
}
13901393
}

src/main/java/com/goxr3plus/streamplayer/stream/StreamPlayerEventLauncher.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
import java.util.List;
2626
import java.util.concurrent.Callable;
27+
import java.util.logging.Level;
28+
import java.util.logging.Logger;
2729

2830
import com.goxr3plus.streamplayer.enums.Status;
2931

@@ -34,6 +36,7 @@
3436
*/
3537
public class StreamPlayerEventLauncher implements Callable<String> {
3638

39+
private final Logger logger;
3740
/** The player state. */
3841
private Status playerState = Status.NOT_SPECIFIED;
3942

@@ -61,15 +64,15 @@ public class StreamPlayerEventLauncher implements Callable<String> {
6164
* @param description
6265
* the description
6366
* @param listeners
64-
* the listeners
6567
*/
66-
public StreamPlayerEventLauncher(Object source, Status playerStatus, int encodedStreamPosition, Object description,
67-
List<StreamPlayerListener> listeners) {
68+
public StreamPlayerEventLauncher(StreamPlayer source, Status playerStatus, int encodedStreamPosition, Object description,
69+
List<StreamPlayerListener> listeners) {
6870
this.source = source;
6971
this.playerState = playerStatus;
7072
this.encodedStreamPosition = encodedStreamPosition;
7173
this.description = description;
7274
this.listeners = listeners;
75+
this.logger = source.getLogger();
7376
}
7477

7578
@Override
@@ -79,8 +82,7 @@ public String call() {
7982
listeners.forEach(listener -> listener
8083
.statusUpdated(new StreamPlayerEvent(source, playerState, encodedStreamPosition, description)));
8184
}
82-
83-
System.out.println("Stream player Status -> " + playerState);
85+
logger.log(Level.INFO, "Stream player Status -> " + playerState);
8486
return "OK";
8587
}
8688
}

0 commit comments

Comments
 (0)