Formatted MultiPlayer.java

This commit is contained in:
Prathamesh More 2022-01-01 22:10:17 +05:30
parent 78c765fcac
commit 3d6bf809f8

View file

@ -31,7 +31,9 @@ import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.service.playback.Playback; import code.name.monkey.retromusic.service.playback.Playback;
import code.name.monkey.retromusic.util.PreferenceUtil; import code.name.monkey.retromusic.util.PreferenceUtil;
/** @author Andrew Neal, Karim Abou Zeid (kabouzeid) */ /**
* @author Andrew Neal, Karim Abou Zeid (kabouzeid)
*/
public class MultiPlayer public class MultiPlayer
implements Playback, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener { implements Playback, MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener {
public static final String TAG = MultiPlayer.class.getSimpleName(); public static final String TAG = MultiPlayer.class.getSimpleName();
@ -40,12 +42,14 @@ public class MultiPlayer
private MediaPlayer mNextMediaPlayer; private MediaPlayer mNextMediaPlayer;
private final Context context; private final Context context;
@Nullable @Nullable
private Playback.PlaybackCallbacks callbacks; private Playback.PlaybackCallbacks callbacks;
private boolean mIsInitialized = false; private boolean mIsInitialized = false;
/** Constructor of <code>MultiPlayer</code> */ /**
* Constructor of <code>MultiPlayer</code>
*/
MultiPlayer(final Context context) { MultiPlayer(final Context context) {
this.context = context; this.context = context;
mCurrentMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mCurrentMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
@ -67,7 +71,7 @@ public class MultiPlayer
/** /**
* @param player The {@link MediaPlayer} to use * @param player The {@link MediaPlayer} to use
* @param path The path of the file, or the http/rtsp URL of the stream you want to play * @param path The path of the file, or the http/rtsp URL of the stream you want to play
* @return True if the <code>player</code> has been prepared and is ready to play, false otherwise * @return True if the <code>player</code> has been prepared and is ready to play, false otherwise
*/ */
private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) { private boolean setDataSourceImpl(@NonNull final MediaPlayer player, @NonNull final String path) {
@ -155,13 +159,17 @@ public class MultiPlayer
this.callbacks = callbacks; this.callbacks = callbacks;
} }
/** @return True if the player is ready to go, false otherwise */ /**
* @return True if the player is ready to go, false otherwise
*/
@Override @Override
public boolean isInitialized() { public boolean isInitialized() {
return mIsInitialized; return mIsInitialized;
} }
/** Starts or resumes playback. */ /**
* Starts or resumes playback.
*/
@Override @Override
public boolean start() { public boolean start() {
try { try {
@ -172,14 +180,18 @@ public class MultiPlayer
} }
} }
/** Resets the MediaPlayer to its uninitialized state. */ /**
* Resets the MediaPlayer to its uninitialized state.
*/
@Override @Override
public void stop() { public void stop() {
mCurrentMediaPlayer.reset(); mCurrentMediaPlayer.reset();
mIsInitialized = false; mIsInitialized = false;
} }
/** Releases resources associated with this MediaPlayer object. */ /**
* Releases resources associated with this MediaPlayer object.
*/
@Override @Override
public void release() { public void release() {
stop(); stop();
@ -189,7 +201,9 @@ public class MultiPlayer
} }
} }
/** Pauses playback. Call start() to resume. */ /**
* Pauses playback. Call start() to resume.
*/
@Override @Override
public boolean pause() { public boolean pause() {
try { try {
@ -200,7 +214,9 @@ public class MultiPlayer
} }
} }
/** Checks whether the MultiPlayer is playing. */ /**
* Checks whether the MultiPlayer is playing.
*/
@Override @Override
public boolean isPlaying() { public boolean isPlaying() {
return mIsInitialized && mCurrentMediaPlayer.isPlaying(); return mIsInitialized && mCurrentMediaPlayer.isPlaying();
@ -291,7 +307,9 @@ public class MultiPlayer
return mCurrentMediaPlayer.getAudioSessionId(); return mCurrentMediaPlayer.getAudioSessionId();
} }
/** {@inheritDoc} */ /**
* {@inheritDoc}
*/
@Override @Override
public boolean onError(final MediaPlayer mp, final int what, final int extra) { public boolean onError(final MediaPlayer mp, final int what, final int extra) {
mIsInitialized = false; mIsInitialized = false;
@ -308,7 +326,9 @@ public class MultiPlayer
return false; return false;
} }
/** {@inheritDoc} */ /**
* {@inheritDoc}
*/
@Override @Override
public void onCompletion(final MediaPlayer mp) { public void onCompletion(final MediaPlayer mp) {
if (mp.equals(mCurrentMediaPlayer) && mNextMediaPlayer != null) { if (mp.equals(mCurrentMediaPlayer) && mNextMediaPlayer != null) {
@ -323,6 +343,7 @@ public class MultiPlayer
} }
} }
@Override @Override
public void setCrossFadeDuration(int duration) { } public void setCrossFadeDuration(int duration) {
}
} }