apwidgets
Class PMediaPlayer

java.lang.Object
  extended by apwidgets.PMediaPlayer
All Implemented Interfaces:
android.media.MediaPlayer.OnErrorListener, android.media.MediaPlayer.OnPreparedListener

public class PMediaPlayer
extends java.lang.Object
implements android.media.MediaPlayer.OnPreparedListener, android.media.MediaPlayer.OnErrorListener

Wraps PMediaPlayer. For now only sound files are supported. For video see PVideoView.

Author:
Rikard Lundstedt

Constructor Summary
PMediaPlayer(processing.core.PApplet pApplet)
          Creates new PMediaPlayer
 
Method Summary
 int getCurrentPosition()
          Get the current position.
 int getDuration()
          Get the duration of the sound
 boolean onError(android.media.MediaPlayer mediaPlayer, int a, int b)
           
 void onPrepared(android.media.MediaPlayer mp)
          When this is called, the player is ready to start playing etc.
 void pause()
          Pause the playing of the file
 void release()
          Release the MediaPlayer
 void seekTo(int msec)
          move to a point in the file, counted from the beginning in millisecond.
 void setLooping(boolean looping)
          Set this to true to loop the play back.
 void setMediaFile(java.lang.String file)
          Set the media file by filename
 void setVolume(float left, float right)
          Sets the volume.
 void start()
          Start playing the file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PMediaPlayer

public PMediaPlayer(processing.core.PApplet pApplet)
Creates new PMediaPlayer

Parameters:
pApplet -
Method Detail

setMediaFile

public void setMediaFile(java.lang.String file)
Set the media file by filename

Parameters:
file -

start

public void start()
Start playing the file


pause

public void pause()
Pause the playing of the file


seekTo

public void seekTo(int msec)
move to a point in the file, counted from the beginning in millisecond.

Parameters:
msec -

release

public void release()
Release the MediaPlayer


setLooping

public void setLooping(boolean looping)
Set this to true to loop the play back.

Parameters:
looping -

setVolume

public void setVolume(float left,
                      float right)
Sets the volume. Left and right are flipped it seems.

Parameters:
left -
right -

getCurrentPosition

public int getCurrentPosition()
Get the current position.

Returns:

getDuration

public int getDuration()
Get the duration of the sound

Returns:

onPrepared

public void onPrepared(android.media.MediaPlayer mp)
When this is called, the player is ready to start playing etc.

Specified by:
onPrepared in interface android.media.MediaPlayer.OnPreparedListener

onError

public boolean onError(android.media.MediaPlayer mediaPlayer,
                       int a,
                       int b)
Specified by:
onError in interface android.media.MediaPlayer.OnErrorListener