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. How to set static ip for wifi configuration

Hi

I have android device and i want to add one wifi configuration with static
ip.
I have done this with the following code.

               WifiManager wifi = (WifiManager)
getSystemService(Context.WIFI_SERVICE);
WifiConfiguration wc = new WifiConfiguration();
wc.SSID = "\"MyWifi\"";
wc.hiddenSSID = true;
wc.status = WifiConfiguration.Status.DISABLED;
wc.priority = 40;
wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
                wifi.addNetwork(wc);

But i don't know where to assign an ip address.

Thanks in advance
saikiran

-- 

2. WTHelp: DHD update

Dear RR, saya menerima notifikasi update system di DHD saya yg sudah di root.
Saya download dan saya update... Eeehhh muncul gambar sbb ( as attach ). 
Dan tanda ini muncul di layar tidak bisa hilang, apakah itu tandanya DHD sedang 
update? Atau ada kesalahan?

Apakah DHD yang sudah diroot bisa di update OTA? Apa yg harus saya lakukan? 

Thanks a lot.
Regards, 
R Bg Andr345 
Sent from my lackerr
White 9780|6.0.0.359

-- 
===============

3. Android Beginner Having Problems

4. how to increase voice recording time?

5. how to increase voice recoding time?

6. Disappearing Images

7. SIGSEGV on free()