|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.audio.Stream
public abstract class Stream
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.
| 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 |
|---|
public static final int MIN_SAMPLE_RATE
public static final int MAX_SAMPLE_RATE
public static final int SAMPLE_RATE_8K
public static final int SAMPLE_RATE_11K
public static final int SAMPLE_RATE_22K
public static final int SAMPLE_RATE_44K
protected Object mLock
| Method Detail |
|---|
public void destroy()
destroy in interface Playabledestroy in interface PlayableMedia
public static Stream load(byte[] data,
boolean autoDelete)
load(byte [])
public static Stream load(byte[] data)
public static Stream play(byte[] data)
start() without the filters.
public static Stream load(int resourceID,
boolean autoDelete)
load(int)
public static Stream load(int resourceID)
public static Stream play(int resourceID)
start() without the filters.
public static Stream play(int resourceID,
int filter)
public static Stream load(File f,
boolean autoDelete)
load(File)
public static Stream load(File f)
public static Stream play(File f,
boolean autoDelete)
play(File)
start() without the filters.
public static Stream play(File f)
start() without the filters.
public final void play()
start()s without the filters.
public abstract boolean loadFromFile(byte[] data)
public abstract boolean loadFromFileName(String fileName)
public boolean loadFromResource(int id)
id - resource ID
public boolean loadFromResource(int id,
Application app)
id - resource IDapp - a specific Application bundle
public abstract int getPlaybackLength()
public abstract int getPlaybackPosition()
public abstract void setPlaybackPosition(int sampleFrame)
public int getMicrosecondLength()
getMillisecondLength() instead.
public void setMicrosecondPosition(int uSec)
setMillisecondPosition(int) instead.
public int getMicrosecondPosition()
getMillisecondPosition() instead.
public int microsecondsToFrames(int uSec)
public int framesToMicroseconds(int frames)
public int millisecondsToFrames(int milliSec)
public int framesToMilliseconds(int frames)
public abstract void setLoops(int loops)
setLoopCount(int) instead.
start().
public abstract void setRate(int newRate)
newRate - range is MIN_SAMPLE_RATE to MAX_SAMPLE_RATEpublic abstract int getRate()
MIN_SAMPLE_RATE to MAX_SAMPLE_RATEpublic boolean startDefault()
start()
public boolean startWithFilter(int filter)
If you pass in ToneFilter.BUZZER or ToneFilter.FLASHER, then the flash and buzz will be synthetically generated.
filter - one of ToneFilter
public boolean start()
public boolean start(int sampleFrameStart)
sampleFrameStart - sample frame offset to start from other than the begining
public boolean start(int sampleFrameStart,
int filter)
If you pass in ToneFilter.BUZZER or ToneFilter.FLASHER, then the flash and buzz will be synthetically generated.
sampleFrameStart - sample frame offset to start from other than the beginingfilter - one of ToneFilterpublic void setRouteBus(int routeBus)
routeBus - one of Routepublic void setVolume(int volume)
setVolume in interface PlayablesetVolume in interface PlayableAudiovolume - 0 to 100 volume.public int getVolume()
getVolume in interface PlayablegetVolume in interface PlayableAudiopublic void setPriority(int priority)
PlayableMedia
setPriority in interface PlayableMediapriority - - priority level for mediapublic int getPriority()
PlayableMedia
getPriority in interface PlayableMediapublic int getLoops()
getLoopCount() instead.
getLoops in interface Playablepublic void setLoopCount(int loopCount)
PlayableMedia
setLoopCount in interface PlayableMedialoopCount - - total number of times to play; 0 means loop forever.public int getLoopCount()
PlayableMedia
getLoopCount in interface PlayableMedia
public void setBuzzFlashEnable(boolean buzzOn,
boolean flashOn)
PlayableAudio
setBuzzFlashEnable in interface PlayableAudiobuzzOn - if true, media will use vibrationflashOn - if true, media will use LEDpublic void setFlashOnlyEnable(boolean flashOnly)
flashOnly - true to disable mood lights, false to enable them
public void setBuzzFlash(boolean buzzOn,
boolean flashOn)
PlayableAudio
setBuzzFlash in interface PlayableAudiobuzzOn - if true, media will generate vibrationflashOn - if true, media will generate LED
public void fadeFromToInTime(int sourceVolume,
int destVolume,
int timeInMilliseconds)
PlayableAudio
fadeFromToInTime in interface PlayableAudiosourceVolume - range 0 to 100destVolume - range 0 to 100timeInMilliseconds - how long the fade takespublic boolean isLoaded()
isLoaded in interface PlayableisLoaded in interface PlayableMediapublic boolean isPaused()
isPaused in interface PlayableisPaused in interface PlayableMediapublic void pause()
pause in interface Playablepause in interface PlayableMediapublic void resume()
resume in interface Playableresume in interface PlayableMediapublic int getMillisecondLength()
PlayableMedia
getMillisecondLength in interface PlayableMediapublic int getMillisecondPosition()
PlayableMedia
getMillisecondPosition in interface PlayableMediapublic void setMillisecondPosition(int position)
PlayableMedia
setMillisecondPosition in interface PlayableMediaposition - position in media to seek topublic int getUniqueID()
getUniqueID in interface PlayablegetUniqueID in interface PlayableMediapublic int getMediaType()
PlayableMedia
getMediaType in interface PlayableMediapublic void setVolumeClass(int volumeClass)
setVolumeClass in interface PlayableAudiovolumeClass - one of VolumeSelectorpublic int getVolumeClass()
getVolumeClass in interface PlayableAudioVolumeSelectorpublic void setLoopingEnabled(boolean on)
PlayableMediaPlayableMedia.setLoopCount(int) or is 0 (loop forever) by default.
setLoopingEnabled in interface PlayableMediaon - enable or disable looping.public boolean isLoopingEnabled()
PlayableMediaPlayableMedia.setLoopingEnabled(boolean)).
isLoopingEnabled in interface PlayableMediapublic int getCurrentLoopNumber()
PlayableMedia
getCurrentLoopNumber in interface PlayableMediapublic int getMarkerCount()
MarkableMedia
getMarkerCount in interface MarkableMediagetMarkerCount in interface PlayableMediapublic int getMarkerIDByIndex(int index)
MarkableMedia
getMarkerIDByIndex in interface MarkableMediaindex - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))public int getMarkerID(int index)
PlayableMedia
getMarkerID in interface PlayableMediapublic String getMarkerNameByIndex(int index)
MarkableMedia
getMarkerNameByIndex in interface MarkableMediaindex - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))public String getMarkerNameByID(int markerID)
MarkableMedia
getMarkerNameByID in interface MarkableMediamarkerID - integer ID of the marker (retrieved via MarkableMedia.getMarkerIDByIndex(int))public String getMarkerName(int index)
PlayableMedia
getMarkerName in interface PlayableMediapublic int getMarkerPositionByIndex(int index)
MarkableMedia
getMarkerPositionByIndex in interface MarkableMediaindex - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))public int getMarkerPositionByID(int markerID)
MarkableMedia
getMarkerPositionByID in interface MarkableMediamarkerID - integer ID of the marker (retrieved via MarkableMedia.getMarkerIDByIndex(int))public int getMarkerPosition(int index)
PlayableMedia
getMarkerPosition in interface PlayableMediapublic void setPositionToMarkerByIndex(int index)
MarkableMedia
setPositionToMarkerByIndex in interface MarkableMediaindex - index of the marker (0 to (MarkableMedia.getMarkerCount() - 1))public void setPositionToMarkerByID(int markerID)
MarkableMedia
setPositionToMarkerByID in interface MarkableMediamarkerID - integer ID of the marker (retrieved via MarkableMedia.getMarkerIDByIndex(int))public void setPositionToMarker(int markerID)
PlayableMedia
setPositionToMarker in interface PlayableMediapublic void setStereoPosition(int position)
PlayableAudio
setStereoPosition in interface PlayableAudioposition - range is -100 (full left) to 100 (full right). Default is 0 (center)public int getStereoPosition()
PlayableAudio
getStereoPosition in interface PlayableAudiopublic void setMute(boolean mute)
PlayableAudio
setMute in interface PlayableAudiomute - true will mute, false will unmutepublic boolean isMuted()
PlayableAudio
isMuted in interface PlayableAudiopublic void startPlaying()
PlayableMedia
startPlaying in interface PlayableMediapublic void startPlaying(int attributes)
PlayableMedia
startPlaying in interface PlayableMediaattributes - - class-specific attributes applied to this playbackpublic boolean isPlaying()
PlayableMedia
isPlaying in interface PlayableMediapublic boolean isDone()
isDone in interface PlayableisDone in interface PlayableMediapublic void stopPlaying()
PlayableMedia
stopPlaying in interface PlayableMediapublic void setPlaybackRate(int newRate)
setPlaybackRate in interface PlayableMedianewRate - rate of playback. 100 is normal, 200 is double speed,
50 is half speedpublic int getPlaybackRate()
getPlaybackRate in interface PlayableMediapublic void setTranspose(int semitones)
setTuning(int) and getTuning().
A semitone, or half-step is a musical interval. A full octave is 12 semitones.
setTranspose in interface PlayableAudiosemitones - range -12 to 12public int getTranspose()
setTuning(int) has been called, This will truncate actual value to nearest 100 cents.
getTranspose in interface PlayableAudiopublic void setTuning(int cents)
setTranspose(int) and getTranspose().
setTuning in interface PlayableAudiocents - 1200 is down an octave, -1200 is up an octavepublic int getTuning()
setTranspose(int) and getTranspose()
getTuning in interface PlayableAudio
public void setPositionCallbackEvent(Event event,
int position)
PlayableMedia
setPositionCallbackEvent in interface PlayableMediaevent - - event to be postedposition - - time in milliseconds at which the event should be postedpublic void setDoneCallbackEvent(Event done)
PlayableMedia
setDoneCallbackEvent in interface PlayableMediadone - - event to be posted
public void setDoneCallbackEvent(Event done,
boolean doEventOnce)
PlayableMedia
setDoneCallbackEvent in interface PlayableMediadone - - event to be posteddoEventOnce - - if true, callback only called once for a given playbackpublic void setStoppedCallbackEvent(Event stopped)
PlayableMedia
setStoppedCallbackEvent in interface PlayableMediastopped - - event to be posted
public void setStoppedCallbackEvent(Event stopped,
boolean doEventOnce)
PlayableMedia
setStoppedCallbackEvent in interface PlayableMediastopped - - event to be posteddoEventOnce - - if true, callback only called once for a given playbackpublic boolean startAtOffset(int startOffset)
startOffset - offset in milliseconds.public void stop()
stop in interface Playable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||