Frage

I want to develop activity or fragment like Youtube.

"When user click on video from list it start playing in small video view like height =200dp and width = 300dp(as example) and i want to display full screen button on MediaPlayer controller by using User can play same video in full screen with effecting video play.

Also i want to display related videoList and comments on current playing video So should i use fragments?? IF yes any sample example.

I search on google about such kind of video play but i don't find it.. there are some answer like use fill parent in height and width ... but i don't want to display full screen directly.

I want to display video in both size small and full screen. How can i do that In image you can see fullscreen button in video controller i want to do that.

Any help is appreciated

Thank youenter image description here

War es hilfreich?

Lösung

try to create small video surface or video view and can change the parameter of view by display matrix

  DisplayMetrics displaymetrics = new DisplayMetrics();
  getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
  int height = displaymetrics.heightPixels;
  int width = displaymetrics.widthPixels;

  android.widget.FrameLayout.LayoutParams params = (android.widget.FrameLayout.LayoutParams) videoSurface.getLayoutParams();
  params.width = width;
  params.height=height-80;// -80 for android controls
  params.setMargins(0, 0, 0, 50);

So to execute this code you can create your own Custom media controller or you can use set anchor by extending media controller.

1) Here is Custom media controller link Custom media controller

2)extending media controller and set anchor tag set anchor tag

  public void setAnchorView(final View view) {
super.setAnchorView(view);

Button fullScreen = new Button(context);
fullScreen.setText("FullScreen");
Log.e("media controller","Set anchorView");
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params.setMargins(view.getWidth(), 0, 5, 20);
params.gravity =  Gravity.RIGHT;
addView(fullScreen, params);

fullScreen.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        Log.e("media controller","full screen onclick");

        Intent i = new Intent("xyxyxyxhx");

        context.sendBroadcast(i);

    }
});
    }

Andere Tipps

You have to override setAnchorView in your new java class which extend the Android's MediaController (android.widget.MediaController) and add an extra view/button to the controller. And do something like this

@Override 
 public void setAnchorView(View view) {
 super.setAnchorView(view);

 Button fullScreen = new Button(context);
 fullScreen.setText("FullScreen");
 FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
 params.gravity =  Gravity.RIGHT|Gravity.TOP;
 addView(fullScreen, params);
}

now add clicklister to view

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top