Commit 4df5b86a authored by Oliver Adams's avatar Oliver Adams

More javadocs

parent 53c834c7
......@@ -28,6 +28,7 @@ public class InterleavedPlayer extends Player {
* original
*
* @param recording The metadata of the recording to play.
* @throws IOException If there is an issue reading the recordings.
*/
public InterleavedPlayer(Recording recording) throws IOException {
setRecording(recording);
......@@ -67,10 +68,17 @@ public class InterleavedPlayer extends Player {
respeaking.setOnCompletionListener(bothCompletedListener);
}
/**
* Resumes playing the interleaved recording, from the original segment
* where it was last paused.
*/
public void play() {
playOriginal();
}
/**
* Resets the player to the beginning.
*/
public void reset() {
originalSegmentIterator = null;
currentOriginalSegment = null;
......@@ -78,7 +86,11 @@ public class InterleavedPlayer extends Player {
respeaking.seekToSample(0l);
}
/** Indicates whether the recording is currently being played. */
/**
* Indicates whether the recording is currently being played.
*
* @return true if the recording is currently playing; false otherwise.
*/
public boolean isPlaying() {
return original.isPlaying() || respeaking.isPlaying();
}
......@@ -93,12 +105,20 @@ public class InterleavedPlayer extends Player {
}
}
/** Get current point in the recording in milliseconds. */
/**
* Get current point in the recording in milliseconds.
*
* @return The current point in the recording in milliseconds as an int.
*/
public int getCurrentMsec() {
return original.getCurrentMsec();
}
/** Get the duration of the recording in milliseconds. */
/**
* Get the duration of the recording in milliseconds.
*
* @return The duration of the recording in milliseconds as an int.
*/
public int getDurationMsec() {
return original.getDurationMsec();
}
......@@ -204,6 +224,11 @@ public class InterleavedPlayer extends Player {
}
}
/**
* Gets the sample rate of this player.
*
* @return The sample rate of the player as a long.
*/
public long getSampleRate() {
//If the sample rate is less than zero, then this indicates that there
//wasn't a sample rate found in the metadata file.
......@@ -218,6 +243,12 @@ public class InterleavedPlayer extends Player {
this.sampleRate = sampleRate;
}
/**
* Converts samples to milliseconds assuming this players sample rate
*
* @param sample A sample value to be converted
* @return The value in milliseconds as an int.
*/
public int sampleToMsec(long sample) {
long msec = sample / (getSampleRate() / 1000);
if (msec > Integer.MAX_VALUE) {
......@@ -226,19 +257,25 @@ public class InterleavedPlayer extends Player {
return (int) msec;
}
private static boolean completedOnce = false;
private long sampleRate;
//////////////////////////////////////////////////////////////////////////
/** Seek to a given point in the recording in milliseconds. */
/**
* Seek to a given point in the recording in milliseconds.
*
* @param msec The point in the recording to seek to in milliseconds.
*/
public void seekToMsec(int msec) {
original.seekToMsec(msec);
}
/** Set the callback to be run when the recording completes playing. */
/**
* Set the callback to be run when the recording completes playing.
*
* @param listener The callback to call when playing is complete.
*/
public void setOnCompletionListener(
final Player.OnCompletionListener listener) {
this.onCompletionListener = listener;
}
private static boolean completedOnce = false;
private long sampleRate;
}
......@@ -18,6 +18,15 @@ import org.lp20.aikuma.model.Segments.Segment;
*/
public class MarkedPlayer extends SimplePlayer {
/**
* Constructor
*
* @param recording The metadata of the recording to be played.
* @param listener The callback to call when a marker is reached.
* @param playThroughSpeaker True if the audio is to be played through the main
* speaker; false if through the ear piece (ie the private phone call style)
* @throws IOException If there is an issue reading from the data source.
*/
public MarkedPlayer(Recording recording, OnMarkerReachedListener listener,
boolean playThroughSpeaker) throws IOException {
super(recording, playThroughSpeaker);
......@@ -47,21 +56,34 @@ public class MarkedPlayer extends SimplePlayer {
this.notificationMarkerPosition = notificationMarkerPosition;
}
/** Sets the notification marker to be at the end of the supplied segment */
/**
* Sets the notification marker to be at the end of the supplied segment
*
* @param segment The segment whose end is to be marked.
*/
public void setNotificationMarkerPosition(Segment segment) {
setNotificationMarkerPositionMsec(
sampleToMsec(segment.getEndSample()));
}
/**
* Removes the marker if it has been set.
*/
public void unsetNotificationMarkerPosition() {
setNotificationMarkerPositionMsec(-1);
}
@Override
public void release() {
super.release();
stopNotificationMarkerLoop();
}
/**
* Seeks to the beginning of the given segment.
*
* @param segment The segment to seek to.
*/
public void seekTo(Segment segment) {
super.seekToSample(segment.getStartSample());
}
......@@ -71,9 +93,15 @@ public class MarkedPlayer extends SimplePlayer {
* reached.
*/
public static abstract class OnMarkerReachedListener {
/**
* The method to be called when the set marker is reached.
*
* @param p The marked player whose marker has been reached.
*/
public abstract void onMarkerReached(MarkedPlayer p);
}
@Override
public void setOnCompletionListener(final OnCompletionListener listener) {
super.setOnCompletionListener(
new Player.OnCompletionListener() {
......
......@@ -15,6 +15,7 @@ public class Processor {
/** Evaluates the average amplitude.
*
* @param buffer The buffer containing the audio data.
* @return Average amplitude of the buffer.
*/
public int getAverage(short[] buffer) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment