MediaController is not working properly with MediaPlayer

by manoj » Mon, 22 Jun 2009 14:38:02 GMT


Sponsored Links
 i,

I want to enable the MediaController for the MediaPlayer.

For this I have written the code like this:

public class AudioPlayerNew extends Activity implements
MediaPlayerControl,MediaPlayer.OnPreparedListener,MediaPlayer.OnBufferingUpdateListener
{
MediaController mediaController;
MediaPlayer mMediaPlayer;
private String path = "/sdcard/Kaarulo Shikarukelle.mp3";
int percent = 1;
boolean playerState = true;

public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.sdcard_media_view);
mediaController = (MediaController) findViewById
(R.id.MediaController01);
playAudio(path);
mediaController.setAnchorView( findViewById
(R.layout.sdcard_media_view));
mediaController.setMediaPlayer(this);
mediaController.bringToFront();
mediaController.setEnabled(true);
}

private void playAudio(String media)
{
try
{
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.prepare();

mMediaPlayer.setOnSeekCompleteListener(this);

mMediaPlayer.setOnPreparedListener(this);

mMediaPlayer.setOnCompletionListener(this);

mMediaPlayer.setOnErrorListener(this);
}
catch (Exception e)
{
Log.e(TAG, "error: " + e.getMessage(), e);
}

}

@Override
protected void onDestroy() {
super.onDestroy();
// TODO Auto-generated method stub
dismissDialog();
if(null != mMediaPlayer)
{
mMediaPlayer.release();
mMediaPlayer = null;
}


wakeLock.release();
}

@Override
public int getBufferPercentage() {
System.out.println("MediaController.getBufferPercentage()
called!!!");
// TODO Auto-generated method stub
return percent;
}

@Override
public int getCurrentPosition() {
System.out.println("MediaController.getCurrentPosition()
called!!!");
// TODO Auto-generated method stub
return mMediaPlayer.getCurrentPosition();
}

@Override
public int getDuration() {
System.out.println("MediaController.getDuration() called!!!");
// TODO Auto-generated method stub
return mMediaPlayer.getDuration();
}

@Override
public boolean isPlaying()
{
//System.out.println("MediaController.isPlaying() called!!!");
// TODO Auto-generated method stub
return playerState;
}

@Override
public void pause()
{
//System.out.println("MediaController.pause() called!!!");
// TODO Auto-generated method stub
if(null != mMediaPlayer)
{
mMediaPlayer.pause();



MediaController is not working properly with MediaPlayer

by manoj » Mon, 22 Jun 2009 17:26:46 GMT


 i, why can't my seek bar (with time) is not updating according to
mediaplayer time.

Can any one please help me.

Thanks,
Manoj.

On Jun 22, 11:37am, manoj <manojkumar.m...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


MediaController is not working properly with MediaPlayer

by manoj » Mon, 22 Jun 2009 19:48:22 GMT


 inally, I solved it!!!

On Jun 22, 2:26pm, manoj <manojkumar.m...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~



MediaController is not working properly with MediaPlayer

by plun » Mon, 27 Jul 2009 06:45:59 GMT


 i Manoj,

I'm having trouble with this too. How did you get it working?
(The Mediacontroller won't display on the Mediaplayer)

On Jun 22, 4:48am, manoj <manojkumar.m...@gmail.com> wrote:

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. problem about ddms

a simple problem from rookie

one day, i opened ddms and created a filter in logcat,

however, i fill a string into "by pid" column by mistake, and after
pressed ok, logcat can not start any longer.

Would you please tell me how to delete the wrong record. Thanks a
lot!!


--~--~---------~--~----~------------~-------~--~----~

2. sharing permission

Does anyone have a suggestion on what could be done to allow a package
signed using certificate A to define a permission that could be
accessed by a package signed using certificate B?

Thanks,

Dirk

3. How can we change image after a specific interval of time.

4. Apps from SD card (no not another can it be done thread)..

5. How to get default applications intent

6. OpenCore RTSP expected messaging replies...

7. brightstar?