public final class Player extends AndroidNonvisibleComponent implements Component, android.media.MediaPlayer.OnCompletionListener, OnPauseListener, OnResumeListener, OnDestroyListener, OnStopListener, Deleteable
MediaPlayer
.Modifier and Type | Field and Description |
---|---|
int |
playerState |
form
ACCELEROMETER_SENSITIVITY_MODERATE, ACCELEROMETER_SENSITIVITY_STRONG, ACCELEROMETER_SENSITIVITY_WEAK, ALIGNMENT_CENTER, ALIGNMENT_NORMAL, ALIGNMENT_OPPOSITE, ASSET_DIRECTORY, BUTTON_SHAPE_DEFAULT, BUTTON_SHAPE_OVAL, BUTTON_SHAPE_RECT, BUTTON_SHAPE_ROUNDED, COLOR_BLACK, COLOR_BLUE, COLOR_CYAN, COLOR_DEFAULT, COLOR_DKGRAY, COLOR_GRAY, COLOR_GREEN, COLOR_LTGRAY, COLOR_MAGENTA, COLOR_NONE, COLOR_ORANGE, COLOR_PINK, COLOR_RED, COLOR_WHITE, COLOR_YELLOW, DEFAULT_VALUE_COLOR_BLACK, DEFAULT_VALUE_COLOR_BLUE, DEFAULT_VALUE_COLOR_CYAN, DEFAULT_VALUE_COLOR_DEFAULT, DEFAULT_VALUE_COLOR_DKGRAY, DEFAULT_VALUE_COLOR_GRAY, DEFAULT_VALUE_COLOR_GREEN, DEFAULT_VALUE_COLOR_LTGRAY, DEFAULT_VALUE_COLOR_MAGENTA, DEFAULT_VALUE_COLOR_NONE, DEFAULT_VALUE_COLOR_ORANGE, DEFAULT_VALUE_COLOR_PINK, DEFAULT_VALUE_COLOR_RED, DEFAULT_VALUE_COLOR_WHITE, DEFAULT_VALUE_COLOR_YELLOW, DIRECTION_EAST, DIRECTION_MAX, DIRECTION_MIN, DIRECTION_NONE, DIRECTION_NORTH, DIRECTION_NORTHEAST, DIRECTION_NORTHWEST, DIRECTION_SOUTH, DIRECTION_SOUTHEAST, DIRECTION_SOUTHWEST, DIRECTION_WEST, FONT_DEFAULT_SIZE, LAYOUT_ORIENTATION_HORIZONTAL, LAYOUT_ORIENTATION_VERTICAL, LENGTH_FILL_PARENT, LENGTH_PREFERRED, LENGTH_UNKNOWN, SLIDER_MAX_VALUE, SLIDER_MIN_VALUE, SLIDER_THUMB_VALUE, TOAST_LENGTH_LONG, TOAST_LENGTH_SHORT, TYPEFACE_DEFAULT, TYPEFACE_MONOSPACE, TYPEFACE_SANSSERIF, TYPEFACE_SERIF
Constructor and Description |
---|
Player(ComponentContainer container)
Creates a new Player component.
|
Modifier and Type | Method and Description |
---|---|
void |
Completed()
Indicates that the media has reached the end
|
boolean |
IsPlaying()
Reports whether the media is playing.
|
boolean |
Loop()
Reports whether the playing should loop.
|
void |
Loop(boolean shouldLoop)
Sets the looping property to true or false.
|
void |
onCompletion(android.media.MediaPlayer m) |
void |
onDelete() |
void |
onDestroy() |
void |
onPause() |
void |
onResume() |
void |
onStop() |
void |
OtherPlayerStarted()
Indicates that the other player has requested the focus of media
|
void |
pause()
Pauses when leaving the screen or losing focus.
|
void |
Pause()
Suspends playing the media if it is playing.
|
void |
PlayerError(java.lang.String message) |
boolean |
PlayOnlyInForeground()
Gets the policy whether playing should only work in foreground.
|
void |
PlayOnlyInForeground(boolean shouldForeground)
Sets the property PlayOnlyInForeground to true or false.
|
java.lang.String |
Source()
Returns the path to the audio source
|
void |
Source(java.lang.String path)
Sets the audio source.
|
void |
Start()
Plays the media.
|
void |
Stop()
Stops playing the media and seeks to the beginning of the song.
|
void |
Vibrate(long milliseconds)
Vibrates for specified number of milliseconds.
|
void |
Volume(int vol)
Sets the volume property to a number between 0 and 100.
|
getDispatchDelegate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDispatchDelegate
public Player(ComponentContainer container)
container
- public java.lang.String Source()
public void Source(java.lang.String path)
MediaUtil.determineMediaSource(com.google.appinventor.components.runtime.Form, java.lang.String)
for information about what
a path can be.path
- the path to the audio sourcepublic boolean IsPlaying()
public boolean Loop()
public void Loop(boolean shouldLoop)
shouldLoop
- determines if the playing should looppublic void Volume(int vol)
vol
- the desired volume levelpublic boolean PlayOnlyInForeground()
public void PlayOnlyInForeground(boolean shouldForeground)
shouldForeground
- determines whether plays only in foreground or always.public void Start()
public void Pause()
public void pause()
public void Stop()
public void Vibrate(long milliseconds)
public void PlayerError(java.lang.String message)
public void onCompletion(android.media.MediaPlayer m)
onCompletion
in interface android.media.MediaPlayer.OnCompletionListener
public void Completed()
public void OtherPlayerStarted()
public void onResume()
onResume
in interface OnResumeListener
public void onPause()
onPause
in interface OnPauseListener
public void onStop()
onStop
in interface OnStopListener
public void onDestroy()
onDestroy
in interface OnDestroyListener
public void onDelete()
onDelete
in interface Deleteable