danger.audio
Class Stream

java.lang.Object
  extended by danger.audio.Stream
All Implemented Interfaces:
DynamicRangeCompressibleAudio, Playable, PlayableAudio, MarkableMedia, PlayableMedia


public abstract class Stream
extends Object

The Stream class represents a PCM based audio file. Support for WAV, AIF, MP3, AAC, WMA, AMR-NB is supported, but is streamed during playback rather than consuming memory.

Since:
2.3

Field Summary
static int MAX_SAMPLE_RATE
          max sample rate = 48 kHz
static int MIN_SAMPLE_RATE
          min sample rate = 1 kHz
protected  Object mLock
           
static int SAMPLE_RATE_11K
          common sample rate 11025 kHz
static int SAMPLE_RATE_22K
          common sample rate 22050 kHz
static int SAMPLE_RATE_44K
          common sample rate 44100 kHz
static int SAMPLE_RATE_8K
          common sample rate 8000 kHz
 
Fields inherited from interface danger.media.PlayableMedia
DEFAULT_PRIORITY, PRIORITY_1, PRIORITY_2, PRIORITY_3, PRIORITY_4, PRIORITY_5
 
Method Summary
 void destroy()
          Free internal resources for this object.
 void fadeFromToInTime(int sourceVolume, int destVolume, int timeInMilliseconds)
          Fade from source volume, to dest volume in time milliseconds.
 int framesToMicroseconds(int frames)
          Given sample frames, return microseconds.
 int framesToMilliseconds(int frames)
          Given sample frames, return milliseconds.
 int getCurrentLoopNumber()
          Gets the number of times the looped media has looped back to the loop start.
 int getLoopCount()
          Gets the loop count; which is the total number of times an object is played.
 int getLoops()
          Deprecated. use getLoopCount() instead.
 int getMarkerCount()
          Gets the number of markers contained by the currently loaded media.
 int getMarkerID(int index)
          Return the integer ID associated with the marker at the given index.
 int getMarkerIDByIndex(int index)
          Return the integer ID associated with the marker at the given index.
 String getMarkerName(int index)
          Return the name associated with the marker at the given index.
 String getMarkerNameByID(int markerID)
          Return the name associated with the marker with the given markerID.
 String getMarkerNameByIndex(int index)
          Return the name associated with the marker at the given index.
 int getMarkerPosition(int index)
          Return the position in milliseconds of the marker at the given index.
 int getMarkerPositionByID(int markerID)
          Return the position in milliseconds of the marker with the given markerID.
 int getMarkerPositionByIndex(int index)
          Return the position in milliseconds of the marker at the given index.
 int getMediaType()
          Returns file type of media.
 int getMicrosecondLength()
          Deprecated. use getMillisecondLength() instead.
 int getMicrosecondPosition()
          Deprecated. use getMillisecondPosition() instead.
 int getMillisecondLength()
          Get length in milliseconds of object's media.
 int getMillisecondPosition()
          Get the current playback position of a object in milliseconds.
abstract  int getPlaybackLength()
          Get playback length in sample frames.
abstract  int getPlaybackPosition()
          Get the position in sample frames.
 int getPlaybackRate()
          Get the playback rate
 int getPriority()
          Get media priority level.
abstract  int getRate()
          Get the sample rate.
 int getStereoPosition()
          Returns current stereo position.
 int getTranspose()
          Get tuning in semitones.
 int getTuning()
          Get tuning in cents.
 int getUniqueID()
          Return runtime ID.
 int getVolume()
          Get volume.
 int getVolumeClass()
          Get the current volume class.
 boolean isDone()
          Returns true if object is finished playing.
 boolean isLoaded()
          Returns true if object is loaded and ready to be played.
 boolean isLoopingEnabled()
          Return whether looping is enabled (set by a call to PlayableMedia.setLoopingEnabled(boolean)).
 boolean isMuted()
          Get mute status.
 boolean isPaused()
          Returns true if paused.
 boolean isPlaying()
          Returns true if object is playing.
static Stream load(byte[] data)
          Given an array of bytes, try and load a Stream (Can be a WAV, AIF file) Will return null if data is invalid.
static Stream load(byte[] data, boolean autoDelete)
          Deprecated. As of 4.0, replaced by load(byte [])
static Stream load(File f)
          Given a file, try and load a Stream.
static Stream load(File f, boolean autoDelete)
          Deprecated. As of 4.0, replaced by load(File)
static Stream load(int resourceID)
          Given an resource ID, try and load a Stream (Can be a WAV, AIF file) Will return null if data is invalid.
static Stream load(int resourceID, boolean autoDelete)
          Deprecated. As of 4.0, replaced by load(int)
abstract  boolean loadFromFile(byte[] data)
          pass in data formatted as a AIF, WAV, or au file.
abstract  boolean loadFromFileName(String fileName)
          pass in filename as a string.
 boolean loadFromResource(int id)
          Load compressed resource, and prepare to stream it.
 boolean loadFromResource(int id, Application app)
          Load compressed resource, and prepare to stream it.
 int microsecondsToFrames(int uSec)
          Given microseconds, return sample frames.
 int millisecondsToFrames(int milliSec)
          Given milliseconds, return sample frames.
 void pause()
          Will pause object.
 void play()
          Given a stream, start it playing, and auto delete it when done playing.
static Stream play(byte[] data)
          Given an array of bytes load a stream file, start it playing, and auto delete it when done playing.
static Stream play(File f)
          Given a file, try and load a Stream, start it playing, and auto delete it when done playing.
static Stream play(File f, boolean autoDelete)
          Deprecated. As of 4.0, replaced by play(File)
static Stream play(int resourceID)
          method to load a stream file from a resource, start it playing, and auto delete it when done playing.
static Stream play(int resourceID, int filter)
          method to load a stream file from a resource, start it playing, and auto delete it when done playing.
 void resume()
          Will resume object if paused.
 void setBuzzFlash(boolean buzzOn, boolean flashOn)
          Set auto generate buzz/flash on or off.
 void setBuzzFlashEnable(boolean buzzOn, boolean flashOn)
          Set buzz/flash enable on or off.
 void setDoneCallbackEvent(Event done)
          Set the event that is called when this media is finished.
 void setDoneCallbackEvent(Event done, boolean doEventOnce)
          Set the event that is called when this media is finished.
 void setFlashOnlyEnable(boolean flashOnly)
          Enable/disable Mood Lights.
 void setLoopCount(int loopCount)
          Sets the loop count; which is the total number of times an object is played.
 void setLoopingEnabled(boolean on)
          Enable looping.
abstract  void setLoops(int loops)
          Deprecated. use setLoopCount(int) instead.
 void setMicrosecondPosition(int uSec)
          Deprecated. use setMillisecondPosition(int) instead.
 void setMillisecondPosition(int position)
          Set the current playback position of object in milliseconds.
 void setMute(boolean mute)
          Mute or unmute the audio.
abstract  void setPlaybackPosition(int sampleFrame)
          Set the position in sample frames.
 void setPlaybackRate(int newRate)
          Set the playback rate
 void setPositionCallbackEvent(Event event, int position)
          Set an event that is called when this media reaches the given position during playback.
 void setPositionToMarker(int markerID)
          Set the media playback position to the position associated with the marker with the given markerID.
 void setPositionToMarkerByID(int markerID)
          Set the media playback position to the position associated with the marker with the given markerID.
 void setPositionToMarkerByIndex(int index)
          Set the media playback position to the position associated with the marker at the give index.
 void setPriority(int priority)
          Set media priority level.
abstract  void setRate(int newRate)
          Set the sample rate.
 void setRouteBus(int routeBus)
          Set audio route.
 void setStereoPosition(int position)
          Set the stereo position of sound.
 void setStoppedCallbackEvent(Event stopped)
          Set the event that is called when this media is stopped by stop().
 void setStoppedCallbackEvent(Event stopped, boolean doEventOnce)
          Set the event that is called when this media is stopped by stop().
 void setTranspose(int semitones)
          Set tuning in semitones.
 void setTuning(int cents)
          Set tuning in cents.
 void setVolume(int volume)
          Set volume.
 void setVolumeClass(int volumeClass)
          Set the volume class.
 boolean start()
          Start sound playing.
 boolean start(int sampleFrameStart)
          Start sound playing.
 boolean start(int sampleFrameStart, int filter)
          Start sound playing.
 boolean startAtOffset(int startOffset)
          Start object at an offset.
 boolean startDefault()
          Start sound with defaults.
 void startPlaying()
          Start media playback with default attributes.
 void startPlaying(int attributes)
          Start media playback with specified attributes.
 boolean startWithFilter(int filter)
          Start sound with a filter.
 void stop()
          Will stop the object and reset to begining.
 void stopPlaying()
          Stop media playback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_SAMPLE_RATE

public static final int MIN_SAMPLE_RATE
min sample rate = 1 kHz

See Also:
Constant Field Values

MAX_SAMPLE_RATE

public static final int MAX_SAMPLE_RATE
max sample rate = 48 kHz

See Also:
Constant Field Values

SAMPLE_RATE_8K

public static final int SAMPLE_RATE_8K
common sample rate 8000 kHz

See Also:
Constant Field Values

SAMPLE_RATE_11K

public static final int SAMPLE_RATE_11K
common sample rate 11025 kHz

See Also:
Constant Field Values

SAMPLE_RATE_22K

public static final int SAMPLE_RATE_22K
common sample rate 22050 kHz

See Also:
Constant Field Values

SAMPLE_RATE_44K

public static final int SAMPLE_RATE_44K
common sample rate 44100 kHz

See Also:
Constant Field Values

mLock

protected Object mLock
Method Detail

destroy

public void destroy()
Free internal resources for this object. Any attempt to use a destroyed object will cause it to throw an IllegalStateException.

Specified by:
destroy in interface Playable
Specified by:
destroy in interface PlayableMedia

load

public static Stream load(byte[] data,
                          boolean autoDelete)
Deprecated. As of 4.0, replaced by load(byte [])

Given an array of bytes, try and load a Stream (Can be a WAV, AIF file) Will return null if data is invalid. This Stream will auto delete once its been played if requested

Since:
3.0

load

public static Stream load(byte[] data)
Given an array of bytes, try and load a Stream (Can be a WAV, AIF file) Will return null if data is invalid. This Stream will auto delete once its been played.


play

public static Stream play(byte[] data)
Given an array of bytes load a stream file, start it playing, and auto delete it when done playing. This Stream will be played with the filter ToneFilter.BUZZER | ToneFilter.FLASHER, which will create buzz and flash. If you don't want to do that, do a Stream.load() then start() without the filters.


load

public static Stream load(int resourceID,
                          boolean autoDelete)
Deprecated. As of 4.0, replaced by load(int)

Given an resource ID, try and load a Stream (Can be a WAV, AIF file) Will return null if data is invalid. This stream will auto delete once its been played if requested.

Since:
3.0

load

public static Stream load(int resourceID)
Given an resource ID, try and load a Stream (Can be a WAV, AIF file) Will return null if data is invalid. This stream will auto delete once its been played.


play

public static Stream play(int resourceID)
method to load a stream file from a resource, start it playing, and auto delete it when done playing. This Stream will be played with the filter ToneFilter.BUZZER | ToneFilter.FLASHER, which will create buzz and flash. If you don't want to do that, do a Stream.load() then start() without the filters.


play

public static Stream play(int resourceID,
                          int filter)
method to load a stream file from a resource, start it playing, and auto delete it when done playing. You can also pass in a different ToneFilter.* for playback. ToneFilter.BUZZER - enables the buzzer ToneFilter.FLASHER - enables the flasher ToneFilter.NONE - disables all but playback


load

public static Stream load(File f,
                          boolean autoDelete)
Deprecated. As of 4.0, replaced by load(File)

Given a file, try and load a Stream. Will return null if data is invalid. This Stream will auto delete once its been played if requested.

Since:
3.0

load

public static Stream load(File f)
Given a file, try and load a Stream. Will return null if data is invalid. This Stream will auto delete once its been played.


play

public static Stream play(File f,
                          boolean autoDelete)
Deprecated. As of 4.0, replaced by play(File)

Given a file, try and load a Stream, start it playing, and auto delete it when done playing if requested. This Stream will be played with the filter ToneFilter.BUZZER | ToneFilter.FLASHER, which will create buzz and flash. If you don't want to do that, do a Stream.load() then start() without the filters.

Since:
3.0

play

public static Stream play(File f)
Given a file, try and load a Stream, start it playing, and auto delete it when done playing. This Stream will be played with the filter ToneFilter.BUZZER | ToneFilter.FLASHER, which will create buzz and flash. If you don't want to do that, do a Stream.load() then start() without the filters.


play

public final void play()
Given a stream, start it playing, and auto delete it when done playing. This Stream will be played with the filter ToneFilter.BUZZER | ToneFilter.FLASHER, which will create buzz and flash. If you don't want to do that, do a Stream.load() then start()s without the filters.


loadFromFile

public abstract boolean loadFromFile(byte[] data)
pass in data formatted as a AIF, WAV, or au file. Will return false if failed to parse.


loadFromFileName

public abstract boolean loadFromFileName(String fileName)
pass in filename as a string. Will return false if it fails to either create an Stream or preroll.


loadFromResource

public boolean loadFromResource(int id)
Load compressed resource, and prepare to stream it.

Parameters:
id - resource ID
Returns:
boolean true if sucessfull, false for failed

loadFromResource

public boolean loadFromResource(int id,
                                Application app)
Load compressed resource, and prepare to stream it.

Parameters:
id - resource ID
app - a specific Application bundle
Returns:
boolean true if sucessfull, false for failed

getPlaybackLength

public abstract int getPlaybackLength()
Get playback length in sample frames.


getPlaybackPosition

public abstract int getPlaybackPosition()
Get the position in sample frames.


setPlaybackPosition

public abstract void setPlaybackPosition(int sampleFrame)
Set the position in sample frames.


getMicrosecondLength

public int getMicrosecondLength()
Deprecated. use getMillisecondLength() instead.

Get ticks in microseconds of length of sample.


setMicrosecondPosition

public void setMicrosecondPosition(int uSec)
Deprecated. use setMillisecondPosition(int) instead.

Set the current playback position of sample in microseconds.


getMicrosecondPosition

public int getMicrosecondPosition()
Deprecated. use getMillisecondPosition() instead.

Get the current playback position of a sample in microseconds.


microsecondsToFrames

public int microsecondsToFrames(int uSec)
Given microseconds, return sample frames. This figures this using this Stream's sample rate.


framesToMicroseconds

public int framesToMicroseconds(int frames)
Given sample frames, return microseconds. This figures this using this Stream's sample rate.


millisecondsToFrames

public int millisecondsToFrames(int milliSec)
Given milliseconds, return sample frames. This figures this using this Stream's sample rate.

Since:
4.0

framesToMilliseconds

public int framesToMilliseconds(int frames)
Given sample frames, return milliseconds. This figures this using this Stream's sample rate.

Since:
4.0

setLoops

public abstract void setLoops(int loops)
Deprecated. use setLoopCount(int) instead.

Set stream loop counter. The number of times a stream is played is loops. Set after startDefault() or start().

Since:
2.3

setRate

public abstract void setRate(int newRate)
Set the sample rate.

Parameters:
newRate - range is MIN_SAMPLE_RATE to MAX_SAMPLE_RATE

getRate

public abstract int getRate()
Get the sample rate.

Returns:
int range is MIN_SAMPLE_RATE to MAX_SAMPLE_RATE

startDefault

public boolean startDefault()
Start sound with defaults. Same as start()

Returns:
true if started otherwise false.
Since:
2.3

startWithFilter

public boolean startWithFilter(int filter)
Start sound with a filter.

If you pass in ToneFilter.BUZZER or ToneFilter.FLASHER, then the flash and buzz will be synthetically generated.

Parameters:
filter - one of ToneFilter
Returns:
true if started otherwise false.
Since:
2.3

start

public boolean start()
Start sound playing.

Returns:
true if started otherwise false.

start

public boolean start(int sampleFrameStart)
Start sound playing.

Parameters:
sampleFrameStart - sample frame offset to start from other than the begining

start

public boolean start(int sampleFrameStart,
                     int filter)
Start sound playing.

If you pass in ToneFilter.BUZZER or ToneFilter.FLASHER, then the flash and buzz will be synthetically generated.

Parameters:
sampleFrameStart - sample frame offset to start from other than the begining
filter - one of ToneFilter

setRouteBus

public void setRouteBus(int routeBus)
Set audio route.

Parameters:
routeBus - one of Route

setVolume

public void setVolume(int volume)
Set volume.

Specified by:
setVolume in interface Playable
Specified by:
setVolume in interface PlayableAudio
Parameters:
volume - 0 to 100 volume.

getVolume

public int getVolume()
Get volume.

Specified by:
getVolume in interface Playable
Specified by:
getVolume in interface PlayableAudio
Returns:
int 0 to 100 default volume.

setPriority

public void setPriority(int priority)
Description copied from interface: PlayableMedia
Set media priority level.

Specified by:
setPriority in interface PlayableMedia
Parameters:
priority - - priority level for media

getPriority

public int getPriority()
Description copied from interface: PlayableMedia
Get media priority level.

Specified by:
getPriority in interface PlayableMedia
Returns:
current priority level

getLoops

public int getLoops()
Deprecated. use getLoopCount() instead.

Get number of loops to play.

Specified by:
getLoops in interface Playable

setLoopCount

public void setLoopCount(int loopCount)
Description copied from interface: PlayableMedia
Sets the loop count; which is the total number of times an object is played.

Specified by:
setLoopCount in interface PlayableMedia
Parameters:
loopCount - - total number of times to play; 0 means loop forever.

getLoopCount

public int getLoopCount()
Description copied from interface: PlayableMedia
Gets the loop count; which is the total number of times an object is played.

Specified by:
getLoopCount in interface PlayableMedia

setBuzzFlashEnable

public void setBuzzFlashEnable(boolean buzzOn,
                               boolean flashOn)
Description copied from interface: PlayableAudio
Set buzz/flash enable on or off.

Specified by:
setBuzzFlashEnable in interface PlayableAudio
Parameters:
buzzOn - if true, media will use vibration
flashOn - if true, media will use LED

setFlashOnlyEnable

public void setFlashOnlyEnable(boolean flashOnly)
Enable/disable Mood Lights. On some devices in addition to the regular light (known as "flash") there are additional lights (known as "mood lights"), which can be enabled or disabled using this method. If called with true, the mood lights will be disabled and only the regular flash used.

Parameters:
flashOnly - true to disable mood lights, false to enable them

setBuzzFlash

public void setBuzzFlash(boolean buzzOn,
                         boolean flashOn)
Description copied from interface: PlayableAudio
Set auto generate buzz/flash on or off.

Specified by:
setBuzzFlash in interface PlayableAudio
Parameters:
buzzOn - if true, media will generate vibration
flashOn - if true, media will generate LED

fadeFromToInTime

public void fadeFromToInTime(int sourceVolume,
                             int destVolume,
                             int timeInMilliseconds)
Description copied from interface: PlayableAudio
Fade from source volume, to dest volume in time milliseconds. Asynchronous.

Specified by:
fadeFromToInTime in interface PlayableAudio
Parameters:
sourceVolume - range 0 to 100
destVolume - range 0 to 100
timeInMilliseconds - how long the fade takes

isLoaded

public boolean isLoaded()
Returns true if object is loaded and ready to be played.

Specified by:
isLoaded in interface Playable
Specified by:
isLoaded in interface PlayableMedia
Since:
2.3

isPaused

public boolean isPaused()
Returns true if paused.

Specified by:
isPaused in interface Playable
Specified by:
isPaused in interface PlayableMedia

pause

public void pause()
Will pause object. Does nothing if already paused.

Specified by:
pause in interface Playable
Specified by:
pause in interface PlayableMedia

resume

public void resume()
Will resume object if paused. Does nothing if already resumed.

Specified by:
resume in interface Playable
Specified by:
resume in interface PlayableMedia

getMillisecondLength

public int getMillisecondLength()
Description copied from interface: PlayableMedia
Get length in milliseconds of object's media.

Specified by:
getMillisecondLength in interface PlayableMedia

getMillisecondPosition

public int getMillisecondPosition()
Description copied from interface: PlayableMedia
Get the current playback position of a object in milliseconds.

Specified by:
getMillisecondPosition in interface PlayableMedia

setMillisecondPosition

public void setMillisecondPosition(int position)
Description copied from interface: PlayableMedia
Set the current playback position of object in milliseconds. Must call after starting object.

Specified by:
setMillisecondPosition in interface PlayableMedia
Parameters:
position - position in media to seek to

getUniqueID

public int getUniqueID()
Return runtime ID. Unique every time object is started.

Specified by:
getUniqueID in interface Playable
Specified by:
getUniqueID in interface PlayableMedia

getMediaType

public int getMediaType()
Description copied from interface: PlayableMedia
Returns file type of media.

Specified by:
getMediaType in interface PlayableMedia

setVolumeClass

public void setVolumeClass(int volumeClass)
Set the volume class. This determines how the media responds to changes in the system sound profile.

Specified by:
setVolumeClass in interface PlayableAudio
Parameters:
volumeClass - one of VolumeSelector

getVolumeClass

public int getVolumeClass()
Get the current volume class. This determines how the media responds to changes in the system sound profile.

Specified by:
getVolumeClass in interface PlayableAudio
Returns:
one of VolumeSelector

setLoopingEnabled

public void setLoopingEnabled(boolean on)
Description copied from interface: PlayableMedia
Enable looping. This will use the loop counter mLoopCount, which is either set via a call to PlayableMedia.setLoopCount(int) or is 0 (loop forever) by default.

Specified by:
setLoopingEnabled in interface PlayableMedia
Parameters:
on - enable or disable looping.

isLoopingEnabled

public boolean isLoopingEnabled()
Description copied from interface: PlayableMedia
Return whether looping is enabled (set by a call to PlayableMedia.setLoopingEnabled(boolean)).

Specified by:
isLoopingEnabled in interface PlayableMedia
Returns:
enabled - true or false.

getCurrentLoopNumber

public int getCurrentLoopNumber()
Description copied from interface: PlayableMedia
Gets the number of times the looped media has looped back to the loop start.

Specified by:
getCurrentLoopNumber in interface PlayableMedia

getMarkerCount

public int getMarkerCount()
Description copied from interface: MarkableMedia
Gets the number of markers contained by the currently loaded media. These can be video, MIDI, or audio markers.

Specified by:
getMarkerCount in interface MarkableMedia
Specified by:
getMarkerCount in interface PlayableMedia

getMarkerIDByIndex

public int getMarkerIDByIndex(int index)
Description copied from interface: MarkableMedia
Return the integer ID associated with the marker at the given index.

Specified by:
getMarkerIDByIndex in interface MarkableMedia
Parameters:
index - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))

getMarkerID

public int getMarkerID(int index)
Description copied from interface: PlayableMedia
Return the integer ID associated with the marker at the given index.

Specified by:
getMarkerID in interface PlayableMedia

getMarkerNameByIndex

public String getMarkerNameByIndex(int index)
Description copied from interface: MarkableMedia
Return the name associated with the marker at the given index. May return null.

Specified by:
getMarkerNameByIndex in interface MarkableMedia
Parameters:
index - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))

getMarkerNameByID

public String getMarkerNameByID(int markerID)
Description copied from interface: MarkableMedia
Return the name associated with the marker with the given markerID. May return null.

Specified by:
getMarkerNameByID in interface MarkableMedia
Parameters:
markerID - integer ID of the marker (retrieved via MarkableMedia.getMarkerIDByIndex(int))

getMarkerName

public String getMarkerName(int index)
Description copied from interface: PlayableMedia
Return the name associated with the marker at the given index. May return null.

Specified by:
getMarkerName in interface PlayableMedia

getMarkerPositionByIndex

public int getMarkerPositionByIndex(int index)
Description copied from interface: MarkableMedia
Return the position in milliseconds of the marker at the given index.

Specified by:
getMarkerPositionByIndex in interface MarkableMedia
Parameters:
index - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))

getMarkerPositionByID

public int getMarkerPositionByID(int markerID)
Description copied from interface: MarkableMedia
Return the position in milliseconds of the marker with the given markerID.

Specified by:
getMarkerPositionByID in interface MarkableMedia
Parameters:
markerID - integer ID of the marker (retrieved via MarkableMedia.getMarkerIDByIndex(int))

getMarkerPosition

public int getMarkerPosition(int index)
Description copied from interface: PlayableMedia
Return the position in milliseconds of the marker at the given index.

Specified by:
getMarkerPosition in interface PlayableMedia

setPositionToMarkerByIndex

public void setPositionToMarkerByIndex(int index)
Description copied from interface: MarkableMedia
Set the media playback position to the position associated with the marker at the give index.

Specified by:
setPositionToMarkerByIndex in interface MarkableMedia
Parameters:
index - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))

setPositionToMarkerByID

public void setPositionToMarkerByID(int markerID)
Description copied from interface: MarkableMedia
Set the media playback position to the position associated with the marker with the given markerID.

Specified by:
setPositionToMarkerByID in interface MarkableMedia
Parameters:
markerID - integer ID of the marker (retrieved via MarkableMedia.getMarkerIDByIndex(int))

setPositionToMarker

public void setPositionToMarker(int markerID)
Description copied from interface: PlayableMedia
Set the media playback position to the position associated with the marker with the given markerID.

Specified by:
setPositionToMarker in interface PlayableMedia

setStereoPosition

public void setStereoPosition(int position)
Description copied from interface: PlayableAudio
Set the stereo position of sound.

Specified by:
setStereoPosition in interface PlayableAudio
Parameters:
position - range is -100 (full left) to 100 (full right). Default is 0 (center)

getStereoPosition

public int getStereoPosition()
Description copied from interface: PlayableAudio
Returns current stereo position.

Specified by:
getStereoPosition in interface PlayableAudio
Returns:
int range is -100 (full left) to 100 (full right). Default is 0 (center)

setMute

public void setMute(boolean mute)
Description copied from interface: PlayableAudio
Mute or unmute the audio. This is independent of the volume.

Specified by:
setMute in interface PlayableAudio
Parameters:
mute - true will mute, false will unmute

isMuted

public boolean isMuted()
Description copied from interface: PlayableAudio
Get mute status.

Specified by:
isMuted in interface PlayableAudio
Returns:
boolean true if muted, false if not

startPlaying

public void startPlaying()
Description copied from interface: PlayableMedia
Start media playback with default attributes.

Specified by:
startPlaying in interface PlayableMedia

startPlaying

public void startPlaying(int attributes)
Description copied from interface: PlayableMedia
Start media playback with specified attributes.

Specified by:
startPlaying in interface PlayableMedia
Parameters:
attributes - - class-specific attributes applied to this playback

isPlaying

public boolean isPlaying()
Description copied from interface: PlayableMedia
Returns true if object is playing.

Specified by:
isPlaying in interface PlayableMedia

isDone

public boolean isDone()
Returns true if object is finished playing.

Specified by:
isDone in interface Playable
Specified by:
isDone in interface PlayableMedia

stopPlaying

public void stopPlaying()
Description copied from interface: PlayableMedia
Stop media playback.

Specified by:
stopPlaying in interface PlayableMedia

setPlaybackRate

public void setPlaybackRate(int newRate)
Set the playback rate

Specified by:
setPlaybackRate in interface PlayableMedia
Parameters:
newRate - rate of playback. 100 is normal, 200 is double speed, 50 is half speed

getPlaybackRate

public int getPlaybackRate()
Get the playback rate

Specified by:
getPlaybackRate in interface PlayableMedia
Returns:
int rate of playback. 100 is normal, 200 is double speed, 50 is half speed

setTranspose

public void setTranspose(int semitones)
Set tuning in semitones. This interacts with setTuning(int) and getTuning(). A semitone, or half-step is a musical interval. A full octave is 12 semitones.

Specified by:
setTranspose in interface PlayableAudio
Parameters:
semitones - range -12 to 12

getTranspose

public int getTranspose()
Get tuning in semitones. If setTuning(int) has been called, This will truncate actual value to nearest 100 cents.

Specified by:
getTranspose in interface PlayableAudio
Returns:
int semitones

setTuning

public void setTuning(int cents)
Set tuning in cents. This interacts with setTranspose(int) and getTranspose().

Specified by:
setTuning in interface PlayableAudio
Parameters:
cents - 1200 is down an octave, -1200 is up an octave

getTuning

public int getTuning()
Get tuning in cents. This interacts with setTranspose(int) and getTranspose()

Specified by:
getTuning in interface PlayableAudio
Returns:
int 1200 is down an octave, -1200 is up an octave

setPositionCallbackEvent

public void setPositionCallbackEvent(Event event,
                                     int position)
Description copied from interface: PlayableMedia
Set an event that is called when this media reaches the given position during playback. Any number of these may be set. Set event to null to disable a given position's callback.

Specified by:
setPositionCallbackEvent in interface PlayableMedia
Parameters:
event - - event to be posted
position - - time in milliseconds at which the event should be posted

setDoneCallbackEvent

public void setDoneCallbackEvent(Event done)
Description copied from interface: PlayableMedia
Set the event that is called when this media is finished.

Specified by:
setDoneCallbackEvent in interface PlayableMedia
Parameters:
done - - event to be posted

setDoneCallbackEvent

public void setDoneCallbackEvent(Event done,
                                 boolean doEventOnce)
Description copied from interface: PlayableMedia
Set the event that is called when this media is finished.

Specified by:
setDoneCallbackEvent in interface PlayableMedia
Parameters:
done - - event to be posted
doEventOnce - - if true, callback only called once for a given playback

setStoppedCallbackEvent

public void setStoppedCallbackEvent(Event stopped)
Description copied from interface: PlayableMedia
Set the event that is called when this media is stopped by stop().

Specified by:
setStoppedCallbackEvent in interface PlayableMedia
Parameters:
stopped - - event to be posted

setStoppedCallbackEvent

public void setStoppedCallbackEvent(Event stopped,
                                    boolean doEventOnce)
Description copied from interface: PlayableMedia
Set the event that is called when this media is stopped by stop().

Specified by:
setStoppedCallbackEvent in interface PlayableMedia
Parameters:
stopped - - event to be posted
doEventOnce - - if true, callback only called once for a given playback

startAtOffset

public boolean startAtOffset(int startOffset)
Start object at an offset.

Parameters:
startOffset - offset in milliseconds.

stop

public void stop()
Will stop the object and reset to begining.

Specified by:
stop in interface Playable