Playing video using MediaPlayer class

前端 未结 4 2343

I am trying to make use of MediaPlayer class for playing a video file. The problem is video is not getting displayed at all though I can hear the sound in the video

4条回答
  •  别跟我提以往
    2021-02-13 02:23

    You can override the onSizeChanged() function of the SurfaceView class to get and set the size of the view.

    protected void onSizeChanged (int w, int h, int oldw, int oldh)
    

    When ever the screen size has changed, this class is called.

    As a second alternative, you may be able to set the size by setting the layout parameters (unsure if this works with ScrollView):

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        android.view.ViewGroup.LayoutParams lp = this.getLayoutParams();
        lp.width = 1000; // required width
        lp.height = 1000; // required height
        this.setLayoutParams(lp);
    }
    

提交回复
热议问题