How to use MediaController

All your problems with Audio, Video and Images.

How to use MediaController

Postby ezmora » Wed May 12, 2010 8:40 pm

Hi all,

I'm trying to integrate a MediaController on top of a MediaPlayer.
The controller is displayed all right, but its buttons are disabled, and the progress slider
does not respond properly.

I found very little documentation about it and I still don't understand how to use it.
This is very important and urgent for me.
Can anyone who has dealt with it before explain how it works?

Thanks,
Eyal
ezmora
Freshman
Freshman
 
Posts: 9
Joined: Thu Mar 25, 2010 3:48 pm

Top

Postby vanessagarcia1 » Thu May 13, 2010 6:56 am

One of my friend facing same problem but till today we not recognise why this should happen . We tried all possible troubleshooting for this but not success yet .
vanessagarcia1
Freshman
Freshman
 
Posts: 3
Joined: Sat May 08, 2010 7:05 am

Postby ezmora » Thu May 13, 2010 9:30 am

That's unfortunate.
I wish plusminus would publish a tutorial on this topic.
ezmora
Freshman
Freshman
 
Posts: 9
Joined: Thu Mar 25, 2010 3:48 pm

Re: How to use MediaController

Postby JKumar » Wed May 19, 2010 8:58 am

HI,

As per my knowledge, MediaPlayer has its own built-in controller which lets it handle through its life cycle.And MediaController is used for handling VideoView to control the view.

i hope you can fulfill your requirement using MediaPlayer.
Hope the suggestion helps you
Keep posting .It makes us better to understand Android
User avatar
JKumar
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Thu May 13, 2010 8:17 am
Location: INDIA

Re: How to use MediaController

Postby ezmora » Wed May 19, 2010 10:02 pm

So you are saying that the MediaPlayer itself has some sort of internal media controller?
In the documentation (http://developer.android.com/reference/android/widget/MediaController.html) it says that: "A view containing controls for a MediaPlayer....., It takes care of synchronizing the controls with the state of the MediaPlayer". There is nothing there that binds the MediaController to a VideoView.

I am very much lost with this matter.
Any ideas???? :-(
ezmora
Freshman
Freshman
 
Posts: 9
Joined: Thu Mar 25, 2010 3:48 pm

Re: How to use MediaController

Postby plusminus » Thu May 20, 2010 9:21 pm

Hm never use this, but maybe post your implementation of theMediaController.MediaPlayerControl that you pass to setMediaPlayer(...).

Best Regards,
Nicolas
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Re: How to use MediaController

Postby ezmora » Sat May 22, 2010 9:08 pm

I finally got it working! :wink:
Thanks to everyone for their help.

For anyone who is interested, here is how it should be done:

VideoView vv;
private SurfaceHolder holder;
private MediaController controller;
private MediaPlayer mMediaPlayer;


public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main1);
vv = (VideoView)findViewById(R.id.sv);
holder = vv.getHolder();
holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
controller = new MediaController(this);
controller.setMediaPlayer(player_interface);
View anchorView = vv.getParent() instanceof View ? (View)vv.getParent() : vv;
controller.setAnchorView(anchorView);
vv.setMediaController(controller);
}

//Implement the MediaController.MediaPlayerControl interface
private MediaController.MediaPlayerControl player_interface = new MediaController.MediaPlayerControl()
{

public int getBufferPercentage()
{
return 20;
}

public int getCurrentPosition()
{
return mMediaPlayer.getCurrentPosition();
}

public int getDuration()
{
return mMediaPlayer.getDuration();
}

public boolean isPlaying()
{
return mMediaPlayer.isPlaying();
}

public void pause()
{
mMediaPlayer.pause();
}

public void seekTo(int pos)
{
mMediaPlayer.seekTo(pos);
}

public void start()
{
mMediaPlayer.start();
}

@Override
public boolean canPause()
{
// TODO Auto-generated method stub
return true;
}

@Override
public boolean canSeekBackward()
{
// TODO Auto-generated method stub
return true;
}

@Override
public boolean canSeekForward()
{
// TODO Auto-generated method stub
return true;
}
};
Thanks,
Eyal
ezmora
Freshman
Freshman
 
Posts: 9
Joined: Thu Mar 25, 2010 3:48 pm

Re: How to use MediaController

Postby Trumpets » Fri Feb 18, 2011 1:15 am

Is here a way to take a video and play it back in slow motion

I have read when you capture you give the frame rate so How do you slow down the play back ?
Trumpets
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Feb 17, 2011 9:02 pm

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 17 guests