|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.ui.MediaPlayer
public class MediaPlayer
MediaPlayer allows various media to be played. It provides
methods for implementing AUI (Audio User Interface). Since the system cannot
read the resources from the penlet jars, the class is made as abstract and
provides a method to get the resource stream from the penlet. The following
is how the penlet can use the MediaPlayer
this.mediaPlayer = new com.livescribe.ui.MediaPlayer() {
protected InputStream getResourceAsStream(String resource) {
return getClass().getResourceAsStream(resource);
}
};
this.mediaPlayer.play("/audio/foo.mp3");
this.mediaPlayer.play("file:///a/b/c.wav");
this.mediaPlayer.playAudioForNumber(5423);
The methods allow you to play a one or more audio file back to back. The API allows the caller to block till one or more clips has finished playing. The default methods do not wait till the playback finishes and returns immediately after starting the playback.
| Method Summary | |
|---|---|
static String |
getMimeType(String file)
Returns the MIME type of the specified audio file. |
protected InputStream |
getResourceAsStream(String resource)
Allows the penlet to provide the stream for the resource specified. |
boolean |
isAudioPlayerPlaying()
Check if a audio is currently being played. |
boolean |
isMoviePlaying()
Check if a movie is currently being played. |
static MediaPlayer |
newInstance(Penlet penlet)
Create a new instance of MediaPlayer. |
void |
play(AudibleResource audibleResource)
Plays an audible resource object |
void |
play(InputStream stream,
String mimeType)
Plays the stream without waiting for it to finish playing |
void |
play(InputStream stream,
String mimeType,
boolean wait)
Plays the stream with the option of waiting for the clip to finish playing. |
void |
play(InputStream stream,
String mimeType,
boolean wait,
int startOffset,
int byteCount)
Seeks to the position specified by startOffset and plays
the stream for byteCount bytes. |
void |
play(String clip)
Plays the clip without waiting for it to finish playing |
void |
play(String[] clips)
|
void |
play(String[] clips,
boolean wait)
|
void |
play(String clip,
boolean wait)
Plays the clip with the option of waiting for the clip to finish playing. |
void |
playAPM(InputStream stream,
String mimeType)
Plays an APM [ Audio Punctuation Mark ]. |
void |
playAPM(String clip)
Plays an APM [ Audio Punctuation Mark ]. |
void |
playAudioForNumber(int number)
Plays the audio for the number specified. |
void |
playMovie(String[] audio,
String[] frame)
Play a movie. |
void |
playMovieRepeatedly(String[] audio,
String[] frame)
Play a movie repeatedly. |
void |
stop()
Stops the MediaPlayer |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static MediaPlayer newInstance(Penlet penlet)
MediaPlayer.
penlet - if a non-null value is passed, then media player can lookup
resource names on the penlet's jar file and play. If null is
passed, then the above feature will not be supported. Platform
code should pass null.
public final void playAPM(InputStream stream,
String mimeType)
stream - The InputStream for the APM.mimeType - The mime type for this APM.public final void playAPM(String clip)
clip - URL or a path name in the jar of the resource.public final void play(AudibleResource audibleResource)
audibleResource - the AudibleResource
public final void play(InputStream stream,
String mimeType)
stream - the InputStream that contains the media data to play
to playmimeType - the content type of the media
public final void play(InputStream stream,
String mimeType,
boolean wait)
stream - the InputStream that contains the media data to play.mimeType - the content type of the media.wait - true to wait till the clip finishes playing;
false not to wait.
public final void play(InputStream stream,
String mimeType,
boolean wait,
int startOffset,
int byteCount)
startOffset and plays
the stream for byteCount bytes. This does nothing if the
input stream or MIME type are null.
stream - the input stream for the media datamimeType - the media MIME typewait - true to wait until the clip finishes playing
and false to not waitstartOffset - the absolute offset in the stream where the stream
should be positioned for playback. A value less than 0 is ignored
and the stream plays from the start.byteCount - number of bytes from the offset to play. This must be a
positve value.public final void play(String clip)
clip - URL or a path name in the jar of the resource
public final void play(String clip,
boolean wait)
clip - URL or a path name in the jar of the resourcewait - true to wait till the clip finishes playing;
false not to wait.public final void play(String[] clips)
clips - Array of URLs or a path names in the jar of the resource.
the resource
public final void play(String[] clips,
boolean wait)
clips - Array of URLs or a path names in the jar of the resource.wait - true to wait till the clip finishes playing
false not to wait.public void stop()
public final void playAudioForNumber(int number)
number - The number that needs to be announced, e.g. one, two,
three, etc. for one to tenpublic boolean isMoviePlaying()
public boolean isAudioPlayerPlaying()
public void playMovieRepeatedly(String[] audio,
String[] frame)
audio - An array of the audio corresponding to each sub movieframe - An array of the images corresponding to each sub movie
public void playMovie(String[] audio,
String[] frame)
audio - An array of the audio corresponding to each sub movieframe - An array of the images corresponding to each sub movie
sub movieprotected InputStream getResourceAsStream(String resource)
resource - the URL or path of the audio resource.
InputStream.public static String getMimeType(String file)
null then this will return null. If the type
could not be determined, then this returns a default of "audio/wav".
file - get the MIME type of this file
null if the specified file
is null, or a default of "audio/wav" if the type
could not be determined.
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||