Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
code cleanup, added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Apr 30, 2024
1 parent 34e898f commit 9754460
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
11 changes: 3 additions & 8 deletions app/src/main/java/org/nuclearfog/apollo/lastfm/Caller.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,11 @@ public Result call(String method, Map<String, String> params) {
}
try {
lastResult = createResultFromInputStream(inputStream);
} catch (IOException ioEx) {
if (BuildConfig.DEBUG) {
ioEx.printStackTrace();
}
lastResult = new Result(ioEx.getLocalizedMessage());
} catch (SAXException saxEx) {
} catch (IOException | SAXException exception) {
if (BuildConfig.DEBUG) {
saxEx.printStackTrace();
exception.printStackTrace();
}
lastResult = new Result(saxEx.getLocalizedMessage());
lastResult = new Result(exception.getLocalizedMessage());
}
return lastResult;
}
Expand Down
15 changes: 11 additions & 4 deletions app/src/main/java/org/nuclearfog/apollo/player/MultiPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public class MultiPlayer implements Player.Listener {
* crossfade overlay of two tracks in milliseconds
*/
private static final long XFADE_DELAY = 1000;

/**
* number of player instances used for playback
* @see #mPlayers
*/
private static final int PLAYER_INST = 3;

/**
Expand All @@ -97,7 +100,7 @@ public class MultiPlayer implements Player.Listener {
/**
* current mediaplayer's index of {@link #mPlayers}
*/
@IntRange(from=0, to=PLAYER_INST - 1)
@IntRange(from = 0, to = PLAYER_INST - 1)
private int currentPlayer = 0;
/**
* set to true if player was initialized successfully
Expand All @@ -120,7 +123,7 @@ public MultiPlayer(MusicPlaybackService service) {
playerHandler = new Handler(service.getMainLooper());
xfadeHandler = new Handler(service.getMainLooper());
mPreferences = PreferenceUtils.getInstance(service);
for (int i = 0 ; i < mPlayers.length ; i++) {
for (int i = 0; i < mPlayers.length; i++) {
mPlayers[i] = createPlayer(service.getApplicationContext());
mPlayers[i].setAudioSessionId(mPlayers[0].getAudioSessionId());
mPlayers[i].setVolume(0f);
Expand Down Expand Up @@ -202,6 +205,8 @@ public boolean busy() {

/**
* Starts or resumes playback.
*
* @return true if successful, false if another operation is already pending
*/
public boolean play() {
if (xfadeMode == NONE) {
Expand All @@ -216,6 +221,7 @@ public boolean play() {
* Pauses playback. Call start() to resume.
*
* @param force true to stop playback immediately
* @return true if successful, false if another operation is already pending
*/
public boolean pause(boolean force) {
ExoPlayer player = mPlayers[currentPlayer];
Expand Down Expand Up @@ -244,6 +250,8 @@ public void stop() {

/**
* go to next player
*
* @return true if successful, false if another operation is already pending
*/
public boolean next() {
if (xfadeMode == NONE) {
Expand Down Expand Up @@ -330,7 +338,6 @@ public Renderer[] createRenderers(@NonNull Handler eventHandler, @NonNull VideoR
/**
* @param player The {@link ExoPlayer} to use
* @param uri The path of the file, or the http/rtsp URL of the stream you want to play
*
* @return true if initialized
*/
private boolean setDataSourceImpl(ExoPlayer player, @NonNull Uri uri) {
Expand Down

0 comments on commit 9754460

Please sign in to comment.