Hello,
Thanks you for your quick response!
I have tried to implement the workaround which is indicated as
response to question 4). However, it does not work, either. I am going
to detail my implementation, for if you would see any obvious bug that
I have not found out.

The xml view that contains a MediaController:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
<TextView
        android:id="@+id/helloText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"/>
<ImageButton android:id="@+id/mediaplay"
style="@android:style/MediaButton"
android:layout_below="@+id/helloText"
android:src="@android:drawable/ic_media_play"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:enabled="true"
android:clickable="true"
android:onClick="onMediaPlayClicked"/>
<MediaController android:id="@+id/MediaController01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/mediaplay"
android:visibility="visible"
android:soundEffectsEnabled="true"
android:hapticFeedbackEnabled="true"
android:keepScreenOn="true">
</MediaController>
</RelativeLayout>

In first place, at the main activity, when the button "mediaplay" is
clicked, the callback function starts the player, between other
actions:

public void onMediaPlayClicked(View v) {
createMediaPlayer();
    player_interface = new MPlayerCtrl();
    mc = (MediaController)findViewById(R.id.MediaController01);
    player_interface.setmPlayer(mPlayer);
    mc.setVisibility(View.VISIBLE);
    mc.setEnabled(true);
    mc.setKeepScreenOn(true);
    mc.setMediaPlayer(player_interface);
    mPlayer.setOnBufferingUpdateListener(this);
    mc.setAnchorView(v);
    player_interface.start();
    mc.show();
}

On the other hand, the onBufferingUpdate method invokes to 'show'
method:

@Override
        public void onBufferingUpdate(MediaPlayer mp, int arg1) {
                // TODO Auto-generated method stub
                mc.show();
        }

Finally, "player_interface" is an object of MPlayerCtrl class. Its
definitions is the next one:

public class MPlayerCtrl implements
MediaController.MediaPlayerControl{
        private MediaPlayer mPlayer = null;

        public void setmPlayer(MediaPlayer mPlayer) {
                this.mPlayer = mPlayer;
        }

        public MediaPlayer getmPlayer() {
                return mPlayer;
        }

        @Override
        public boolean canPause() {
                return true;
        }

        @Override
        public boolean canSeekBackward() {
                return true;
        }

        @Override
        public boolean canSeekForward() {
                return true;
        }

        @Override
        public int getBufferPercentage() {
                //return percent;
                 return (mPlayer.getCurrentPosition() *100)/ 
mPlayer.getDuration();
        }

        @Override
        public int getCurrentPosition() {
                return mPlayer.getCurrentPosition();
        }

        @Override
        public int getDuration() {
                return mPlayer.getDuration();
        }

        @Override
        public boolean isPlaying() {
                return mPlayer.isPlaying();
        }

        @Override
        public void pause() {
                mPlayer.pause();

        }

        @Override
        public void seekTo(int pos) {
                mPlayer.seekTo(pos);

        }

        @Override
        public void start() {
                mPlayer.start();

        }

}
Thanks in advance,
MJMF

On 14 oct, 21:39, MarcoAndroid <[email protected]> wrote:
> I asked this and a bunch of other questions/strange behaviour I found
> a little while ago 
> here:http://groups.google.com/group/android-developers/browse_thread/threa...
>
> My workaround for your questions might be under quesion 4). Maybe that
> helps.
>
> On 11 okt, 03:56, MJ Moron <[email protected]> wrote:> Hello,
> > The seek bar of Mediacontroller is not been updating according to de
> > audio player. Only when the trackball is shifted, or the play/pause
> > button is clicked,  the seek bar  tracks the audio player.
> > Could anybody give me any clue?
>
> > Thanks in advance

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to