|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.enough.polish.multimedia.AudioPlayer
public class AudioPlayer
Plays back audio files - at the moment this is only supported for MIDP 2.0 and devices that support the MMAPI and for Android devices.
Copyright Enough Software 2006 - 2009
| Field Summary |
|---|
| Fields inherited from interface javax.microedition.media.PlayerListener |
|---|
CLOSED, DEVICE_AVAILABLE, DEVICE_UNAVAILABLE, DURATION_UPDATED, END_OF_MEDIA, ERROR, STARTED, STOPPED, VOLUME_CHANGED |
| Constructor Summary | |
|---|---|
AudioPlayer()
Creates a new audio player with no default content type and no caching. |
|
AudioPlayer(boolean doCachePlayer)
Creates a new audio player with no default content type. |
|
AudioPlayer(boolean doCachePlayer,
String contentType)
Creates a new audio player with no listener |
|
AudioPlayer(boolean doCachePlayer,
String contentType,
PlayerListener listener)
Creates a new audio player |
|
AudioPlayer(String contentType)
Creates a new audio player without caching and with no listener. |
|
| Method Summary | |
|---|---|
void |
cleanUpPlayer()
Closes and deallocates the player. |
static String |
getAudioType(String type,
String protocol)
Helper function for getting a supported media type. |
Player |
getPlayer()
Returns the original player. |
PlayerListener |
getPlayerListener()
Retrieves the currently registered player listener. |
int |
getVolumeLevel()
Gets the volume using a linear point scale with values between 0 and 100. |
boolean |
isMuted()
Detects the the player is currently muted |
boolean |
isPlaying()
Determines if the audio player is currently playing music |
static boolean |
isSupportedAudioType(String type,
String protocol)
Determines whether the given audio format is supported by this device for the specified protocol. |
void |
onCompletion(android.media.MediaPlayer mp)
Informs the audio player about a finished media on Android devices. |
void |
onPrepared(android.media.MediaPlayer p)
|
void |
play()
Plays back the last media again. |
void |
play(InputStream in)
Plays the media taken from the specified input stream with the content type specified in the constructor. |
void |
play(InputStream in,
String type)
Plays the media taken from the specified input stream. |
void |
play(String url)
Plays the media taken from the specified URL with the content type specified in the constructor. |
void |
play(String url,
String type)
Plays the media taken from the specified URL. |
void |
playerUpdate(Player p,
String event,
Object data)
|
void |
prepare(String url)
This method is part of a two-phase playback. |
void |
setMute(boolean mute)
Mutes the player or restores the previous volume level |
void |
setPlayerListener(PlayerListener listener)
Sets a player listener, replacing any previously registered listener. |
void |
setVolumeLevel(int j2MeLevel)
Sets the volume using a linear point scale with values between 0 and 100. |
void |
stop()
|
void |
streamMp3s(String[] filenames)
This method will play the files with the filenames given in the parameter one after the other. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AudioPlayer()
public AudioPlayer(boolean doCachePlayer)
doCachePlayer - caches the player even though the end of the media is reachedpublic AudioPlayer(String contentType)
contentType - the type of the referenced media, this is being resolved to the phone's expected type automatically.
You can, for example, use the type "audio/mp3" and this method resolves the type to "audio/mpeg3", if this
is expected by the device.
public AudioPlayer(boolean doCachePlayer,
String contentType)
doCachePlayer - caches the player even though the end of the media is reachedcontentType - the type of the referenced media, this is being resolved to the phone's expected type automatically.
You can, for example, use the type "audio/mp3" and this method resolves the type to "audio/mpeg3", if this
is expected by the device.
public AudioPlayer(boolean doCachePlayer,
String contentType,
PlayerListener listener)
doCachePlayer - caches the player even though the end of the media is reachedcontentType - the type of the referenced media, this is being resolved to the phone's expected type automatically.
You can, for example, use the type "audio/mp3" and this method resolves the type to "audio/mpeg3", if this
is expected by the device.listener - an optional PlayerListener| Method Detail |
|---|
public void stop()
public void setPlayerListener(PlayerListener listener)
listener - the new listener or nullpublic PlayerListener getPlayerListener()
public void streamMp3s(String[] filenames)
throws IOException
filenames - Must not be null and no array element must be null. Each filename must start with 'file://'. Normally you want
to access files under the directory 'System.getProperty("fileconn.dir.private")'.
IOException
public void play(String url,
String type)
throws MediaException,
IOException
url - the URL of the mediatype - the type of the referenced media, this is being resolved to the phone's expected type automatically.
You can, for example, use the type "audio/mp3" and this method resolves the type to "audio/mpeg3", if this
is expected by the device.
MediaException - when the media is not supported
IOException - when the URL cannot be resolved
public void play(InputStream in,
String type)
throws MediaException,
IOException
in - the media inputtype - the type of the referenced media, this is being resolved to the phone's expected type automatically.
You can, for example, use the type "audio/mp3" and this method resolves the type to "audio/mpeg3", if this
is expected by the device.
MediaException - when the media is not supported
IOException - when the input cannot be read
public void play(String url)
throws MediaException,
IOException
url - the URL of the media
MediaException - when the media is not supported
IOException - when the URL cannot be resolved
public void play(InputStream in)
throws MediaException,
IOException
in - the media input
MediaException - when the media is not supported
IOException - when the input cannot be read
public void play()
throws MediaException
MediaException - when the player cannot be startedAudioPlayer(boolean),
AudioPlayer(boolean, String),
AudioPlayer(boolean, String, PlayerListener),
AudioPlayer(String)public Player getPlayer()
public static String getAudioType(String type,
String protocol)
type - the type like "audio/mp3"protocol - the protocol, when null is given the content type will be
returned for any protocol
public static boolean isSupportedAudioType(String type,
String protocol)
type - the type like "audio/mp3"protocol - the protocol, when null is given the content type will be
returned for any protocol
public boolean isPlaying()
public void playerUpdate(Player p,
String event,
Object data)
playerUpdate in interface PlayerListenerpublic void cleanUpPlayer()
public int getVolumeLevel()
public void setVolumeLevel(int j2MeLevel)
j2MeLevel - the volume level between 0 and 100public boolean isMuted()
public void setMute(boolean mute)
mute - true when the player should be muted, false when the previous volume level should be restoredpublic void onCompletion(android.media.MediaPlayer mp)
onCompletion in interface android.media.MediaPlayer.OnCompletionListenermp - the media player (should be the same as this.mediaPlayer)public void onPrepared(android.media.MediaPlayer p)
onPrepared in interface android.media.MediaPlayer.OnPreparedListener
public void prepare(String url)
throws IOException
play() method.
This method is only available on android at the moment.
url -
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||