|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.audio.AudioManager
public class AudioManager
The AudioManager class is the main factory for creating and playing audio objects.
| Field Summary | |
|---|---|
static int |
DEBUG_GENERAL
Debug level selector bits. |
static int |
DEBUG_NONE
Debug level selector bits. |
static int |
DEBUG_PLAYABLE
Debug level selector bits. |
static int |
DEBUG_SEQUENCE
Debug level selector bits. |
static int |
DEBUG_SOUND
Debug level selector bits. |
static int |
DEBUG_STREAM
Debug level selector bits. |
static int |
DEBUG_SYSTEM
Debug level selector bits. |
static int |
EIGHTH_SECOND
Time constants. |
static int |
ENABLE_RUNTIME_EXCEPTIONS
Player attribute for load: enable runtime exceptions during and after load |
static int |
HALF_SECOND
Time constants. |
static int |
LOAD_ASYNCHRONOUSLY
Player attribute for load: load asynchronously (default is synchronous) |
static int |
MEDIA_ANY
Media id used to query for any media playing. |
static int |
MEDIA_NONE
Media id used when no media is playing. |
static int |
NOW
Time constants. |
static int |
ONE_SECOND
Time constants. |
static int |
QUARTER_SECOND
Time constants. |
| Method Summary | |
|---|---|
static boolean |
areRuntimeExceptionsEnabled(PlayableAudio player)
Query whether runtime exception handling is enabled for an object. |
static boolean |
canCreateRecorder()
If a Recorder can be created with createRecorder(), this will return true, otherwise false |
static BufferedStream |
createBufferedStream()
Create a new BufferedStream object. |
static Recorder |
createRecorder()
Create a new sound Recorder object. |
static Sequence |
createSequence()
Create a new Sequence object. |
static Sequence |
createSequence(boolean autoDelete)
Deprecated. As of 4.0, replaced by createSequence() |
static Sequence |
createSequence(boolean autoDelete,
int type)
Deprecated. As of 4.0, replaced by createSequence() |
static Sound |
createSound()
Create a new Sound object. |
static Sound |
createSound(boolean autoDelete)
Deprecated. As of 4.0, replaced by createSound() |
static Sound |
createSound(boolean autoDelete,
int type)
Deprecated. As of 4.0, replaced by createSound() |
static Stream |
createStream()
Create a new Stream object. |
static Stream |
createStream(boolean autoDelete)
Deprecated. As of 4.0, replaced by createStream() |
static Stream |
createStream(boolean autoDelete,
int type)
Deprecated. As of 4.0, replaced by createStream() |
static void |
enableRuntimeExceptions(PlayableAudio player,
boolean enable)
Enable/disable runtime exception handling for an object. |
static int |
findCodecFromMimeType(String mimeType)
Return Format.Type from passed in mime type String. |
static String |
getCodecMimeType(int fileType)
Deprecated. As of 4.5, replaced by getMimeType(int) |
static int |
getCurrentAudioRoute()
Get the current audio route |
static int |
getDebugLevel()
Get the current debugging level. |
static int |
getFrameSnapshot(short[] left,
short[] right)
If startFrameSnapshot() has been called, and it returned true,
then calls to getFrameSnapshot() will return a copy of the last
audio buffer sent to the hardware. |
static Bitmap |
getMediaStreamIcon(int id)
Get the icon for the given media id. |
static int |
getMediaStreamPlayerIDFromName(String name)
Get the media id from the player name. |
static String |
getMediaStreamPlayerName(int id)
Get the name of the player from the media id. |
static int |
getMediaStreamVolume(int id)
Get the volume for the given stream. |
static String |
getMimeType(int fileType)
Return MIME type from passed in Format.Type.* which can be obtained from getFileType(byte [])
Returns a null string if the FileType is not supported. |
static int |
getMixerRate()
returns sample rate of audio mixer |
static int |
getRecordMonitorLevel()
Get record monitor level |
static int |
getTime()
Get current tick in microseconds. |
static int |
getTimePlusEighthSecond()
Get current time plus a eighth second. |
static int |
getTimePlusHalfSecond()
Get current time plus a half second. |
static int |
getTimePlusOneSecond()
Get current time plus a second. |
static int |
getTimePlusQuarterSecond()
Get current time plus a quarter second. |
static boolean |
includesDebugLevel(int level)
Returns true if global debug level includes the specified level |
static boolean |
isActive()
returns true, if audio system is generating audio |
static boolean |
isBuiltIn()
test to see if audio system is built into rom |
static boolean |
isMediaPlayerRegistered(Listener listener)
Checks to see if the passed in listener is already registered. |
static boolean |
isMediaStream(int id)
Get the volume for the given stream. |
static boolean |
isMediaStreamPlaying(int id)
Returns true if the media stream with this id is playing. |
static boolean |
isNetworkStreamingEnabled()
See if network audio streaming is enabled. |
static boolean |
isRecording()
Are we recording? |
static Object |
load(byte[] data)
Given a byte stream, figure out what kind of audio file it is, if any, and load it. |
static PlayableAudio |
load(byte[] data,
int loadAttributes)
Given a byte stream, figure out what kind of audio file it is, if any, and load it with the given attributes. |
static Object |
load(File file)
Given a File, figure out what kind of audio file it is, if any, and load it. |
static PlayableAudio |
load(File file,
boolean autoDelete)
Deprecated. As of 4.0, replaced by load(File, int) |
static PlayableAudio |
load(File file,
int loadAttributes)
Given a File, figure out what kind of audio file it is, if any, and load it with the given attributes. |
static PlayableAudio |
load(URL url,
int loadAttributes,
Event callbackEvent)
Given a URL, try and load it with the given attributes. |
static Object |
play(byte[] data)
Given a byte stream, figure out what kind of audio file it is, if any, and play it. |
static Object |
play(File file)
Given a File, figure out what kind of audio file it is, if any, and play it. |
static PlayableAudio |
play(URL url)
Given a URL, try to load and play it. |
static void |
playDTMFTone(char toneKey,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
Play one DTMF tone synchronously. |
static void |
playDTMFToneAsync(char toneKey,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
Play one DTMF tone asynchronously. |
static void |
playDTMFToneString(String tones,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
Play DTMF tones synchronously. |
static void |
playDTMFToneStringAsync(String tones,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
Play DTMF tones asynchronously. |
static boolean |
recognize(File file)
Given a File, return whether or not the file is recognized as audio. |
static void |
registerForAudioEvents(Listener inListener)
Register a Listener object to receive audio events. |
static int |
registerMediaPlayer(Listener listener,
String name,
Bitmap icon)
Register a media player to be controlled by the sound controls. |
static void |
setDebugLevel(int level)
Set the global debug level. |
static void |
setMediaStreamVolume(int id,
int volume)
Set the volume for the given stream. |
static void |
start(Object object,
int filters)
Start an audio object. |
static boolean |
startFrameSnapshot()
Turn on snapshot mode. |
static void |
stop(Object object)
Stop and destroy an audio object. |
static void |
stopFrameSnapshot()
Call after finished capturing audio snapshots. |
static void |
testTone(boolean status)
turn on/off a test tone. |
static void |
testToneFrequency(int frequency)
When the tone is enabled, play this frequency. |
static void |
unregisterForAudioEvents(Listener inListener)
Unregister a Listener object to receive audio events |
static void |
unregisterMediaPlayer(int id)
Unregister a media player. |
static void |
vibrate(int inDuration)
Turn on vibration for a period of time. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int ENABLE_RUNTIME_EXCEPTIONS
public static final int LOAD_ASYNCHRONOUSLY
public static final int NOW
public static final int ONE_SECOND
public static final int HALF_SECOND
public static final int QUARTER_SECOND
public static final int EIGHTH_SECOND
public static final int DEBUG_NONE
No debugging.
Used as or'd values for setDebugLevel(int).
public static final int DEBUG_GENERAL
General-purpose debugging (backwards compat).
Used as or'd values for setDebugLevel(int).
public static final int DEBUG_SYSTEM
AudioManager and underlying audio system.
Used as or'd values for setDebugLevel(int).
public static final int DEBUG_PLAYABLE
Functionality common to all Playables.
Used as or'd values for setDebugLevel(int).
public static final int DEBUG_SOUND
Show debugging for Sound.
Used as or'd values for setDebugLevel(int).
public static final int DEBUG_STREAM
Show debugging for Stream.
Used as or'd values for setDebugLevel(int).
public static final int DEBUG_SEQUENCE
Show debugging for Sequence.
Used as or'd values for setDebugLevel(int).
public static final int MEDIA_NONE
public static final int MEDIA_ANY
| Method Detail |
|---|
public static boolean isActive()
public static boolean isBuiltIn()
public static int getMixerRate()
public static void setDebugLevel(int level)
For example will show
DEBUG_STREAM | DEBUG_SOUNDSound and Stream debugging related information.
level - bits OR'd together to get debugging information.public static int getDebugLevel()
public static boolean includesDebugLevel(int level)
public static void vibrate(int inDuration)
inDuration - if > 0 then represents milliseconds, -1 is on, 0 is off.
public static void playDTMFToneStringAsync(String tones,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
tones - a number string. ie. "4154491947"signalLengthInMS - length in milliseconds of each tone.gapBetweenSignalInMS - length in milliseconds of gap between each tone.volume - 0 to 100 volume of tone.
public static void playDTMFToneAsync(char toneKey,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
toneKey - a number character. ie. '4'signalLengthInMS - length in milliseconds of each tone.gapBetweenSignalInMS - length in milliseconds of gap between each tone.volume - 0 to 100 volume of tone.
public static void playDTMFTone(char toneKey,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
toneKey - a number character. ie. '4'signalLengthInMS - length in milliseconds of each tone.gapBetweenSignalInMS - length in milliseconds of gap between each tone.volume - 0 to 100 volume of tone.
public static void playDTMFToneString(String tones,
int signalLengthInMS,
int gapBetweenSignalInMS,
int volume)
tones - a number string. ie. "4154491947"signalLengthInMS - length in milliseconds of each tone.gapBetweenSignalInMS - length in milliseconds of gap between each tone.volume - 0 to 100 volume of tone.public static void testToneFrequency(int frequency)
public static void testTone(boolean status)
public static boolean canCreateRecorder()
public static boolean isRecording()
public static int getRecordMonitorLevel()
public static Recorder createRecorder()
throws AudioException
AudioException
public static Sequence createSequence(boolean autoDelete,
int type)
throws AudioException
createSequence()
AudioException
public static Sequence createSequence(boolean autoDelete)
throws AudioException
createSequence()
AudioException
public static Sequence createSequence()
throws AudioException
AudioException
public static Sound createSound(boolean autoDelete,
int type)
throws AudioException
createSound()
AudioException
public static Sound createSound(boolean autoDelete)
throws AudioException
createSound()
AudioException
public static Sound createSound()
throws AudioException
AudioException
public static Stream createStream(boolean autoDelete,
int type)
throws AudioException
createStream()
AudioException
public static Stream createStream(boolean autoDelete)
throws AudioException
createStream()
AudioException
public static Stream createStream()
throws AudioException
AudioException
public static BufferedStream createBufferedStream()
throws AudioException
AudioException
public static void enableRuntimeExceptions(PlayableAudio player,
boolean enable)
public static boolean areRuntimeExceptionsEnabled(PlayableAudio player)
public static void registerForAudioEvents(Listener inListener)
EventType.EVENT_AUDIO.
Multiple calls for the same listener will be ignored.
inListener - Listener to send events to.
RuntimeException - if inListener is nullpublic static void unregisterForAudioEvents(Listener inListener)
inListener - Listener to remove
RuntimeException - if inListener is null
IllegalArgumentException - if inListener is not currently registeredpublic static int getCurrentAudioRoute()
public static String getCodecMimeType(int fileType)
getMimeType(int)
getFileType(byte [])
public static String getMimeType(int fileType)
getFileType(byte [])
Returns a null string if the FileType is not supported. NOTE: Return value may be changed
in a future release from a null string to "application/unknown".
public static int findCodecFromMimeType(String mimeType)
public static boolean startFrameSnapshot()
stopFrameSnapshot() to turn off mode.
NOTE: This is not frame accurate. This is used for display only.
public static int getFrameSnapshot(short[] left,
short[] right)
startFrameSnapshot() has been called, and it returned true,
then calls to getFrameSnapshot() will return a copy of the last
audio buffer sent to the hardware.
public static void stopFrameSnapshot()
public static int getTime()
One thousand microseconds equal 1 millisecond.
One thousand milliseconds equal 1 second.
Sixty seconds equal 1 minute.
public static int getTimePlusQuarterSecond()
public static int getTimePlusHalfSecond()
public static int getTimePlusOneSecond()
public static int getTimePlusEighthSecond()
public static Object load(byte[] data)
public static Object load(File file)
public static boolean recognize(File file)
public static PlayableAudio load(File file,
boolean autoDelete)
load(File, int)
public static PlayableAudio load(File file,
int loadAttributes)
throws PlayableMediaException
PlayableMediaException
public static PlayableAudio load(byte[] data,
int loadAttributes)
throws PlayableMediaException
PlayableMediaException
public static PlayableAudio load(URL url,
int loadAttributes,
Event callbackEvent)
throws URIException,
IOException,
HttpException,
PlayableMediaException
ENABLE_RUNTIME_EXCEPTIONS.
Loads synchronously unless loadAttributes includes LOAD_ASYNCHRONOUSLY.
Will currently only load streamable audio objects BufferedStream.
If loaded asynchronously, the Playable returned will not be ready to play
until the callbackEvent is called with BufferedStream.Status.WHAT_LOADED,
or PlayableMedia.isLoaded() returns true.
url - the URL to load.loadAttributes - values may be or'd ENABLE_RUNTIME_EXCEPTIONS LOAD_ASYNCHRONOUSLY.callbackEvent - sets the BufferedStream's statusCallbackEvent BufferedStream.setStatusCallbackEvent(danger.app.Event) - may be null.
BufferedStream is returned) or null.
URIException
IOException
HttpException
PlayableMediaExceptionpublic static Object play(byte[] data)
public static Object play(File file)
public static PlayableAudio play(URL url)
url - the URL to load
public static void start(Object object,
int filters)
object - an object returned from play(byte[]) or load(byte[]).filters - one or combined bits of ToneFilter.public static void stop(Object object)
PlayableMedia.destroy()
on the audio object. Since it calls destroy, you cannot make any
additional calls on the object, and it should be nulled immediately upon
return from this method.
object - an object returned from play(byte[]) or load(byte[]).public static boolean isNetworkStreamingEnabled()
public static int registerMediaPlayer(Listener listener,
String name,
Bitmap icon)
EventType.EVENT_AUDIO_MEDIA_VOLUME_CHANGE_REQUESTED event.
The what field of the event contains the media id.
The data field of the event contains the new volume value.
If a media player with this name is already registered,
the listener or name parameter is null, or the media player
cannot be created, an RuntimeException is thrown.
If the media player cannot be created, and you have registered
another media player, you can unregister that one and then
register your new one.
listener - non-null; The target listener.icon - null-ok; The icon to use in the sound controls.
public static void unregisterMediaPlayer(int id)
id - The id of the media player.
public static void setMediaStreamVolume(int id,
int volume)
id - The id of the media streampublic static int getMediaStreamVolume(int id)
id - The id of the media streampublic static boolean isMediaStreamPlaying(int id)
id - The id of a media stream -
Use MEDIA_ANY to see if any media streams are playing.
public static Bitmap getMediaStreamIcon(int id)
id - The id of a media stream.
public static String getMediaStreamPlayerName(int id)
id - The id of a media stream.
public static int getMediaStreamPlayerIDFromName(String name)
name - the media player name
public static boolean isMediaStream(int id)
id - The id of the media streampublic static boolean isMediaPlayerRegistered(Listener listener)
listener - active Listener.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||