How do I change MediaController
icons programmatically? I mean play/pause/forward and rew.
You see I have added fullscreen button but can't realize how to change those three.
Custom MediaController class:
public class CustomVideoController extends MediaController {
public static boolean full = false;
private ImageButton fullScreenBtn;
Context mContext;
Activity activity;
VideoView mVideoView;
public CustomVideoController(Context context, Activity activity, VideoView videoView) {
super(new ContextThemeWrapper(context, R.style.VideoPlayerTheme));
this.activity = activity;
mContext = context;
mVideoView = videoView;
}
@Override
public void setAnchorView(View view) {
super.setAnchorView(view);
FrameLayout.LayoutParams frameParams = new FrameLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
frameParams.gravity = Gravity.RIGHT | Gravity.TOP;
frameParams.setMargins(12,14,10,12);
View v = AddFullScreenBtn();
addView(v, frameParams);
}
@Override
public void hide() {
super.hide();
}
@Override
public void show(int timeout) {
super.show(0);
}
private View AddFullScreenBtn() {
fullScreenBtn = new ImageButton(mContext);
if (full)
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_stretch);
else
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_shrink);
fullScreenBtn.setBackgroundColor(Color.WHITE);
fullScreenBtn.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (full){
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_stretch);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
full = false;
} else {
fullScreenBtn.setImageResource(R.drawable.ic_media_fullscreen_shrink);
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
full = true;
}
}
});
return fullScreenBtn;
}
Please help me to change drawables for those icons. Is it possible at all? I'm really confused with that one.