A problem occurs today. The video cannot be centered.
Assign the entire screen to the videoview when setting the layout of the videoview.
However, during video playback, videos with different aspect ratios are not played to the center.
With the same policy, the imageview can place the image at the center of the screen, which is a problem with viewview.
However, videoview is a functional component of the framework layer, so we come up with a way to avoid it.
Each time you obtain the video resolution and screen length and width, you can compare the screen video width to determine whether the video should be compressed Based on the length or width.
Then, the area of the blank area is determined to set the location of view layout. Therefore, you need to obtain the video resolution.
Mediametadataretriever RETR = new mediametadataretriever (); RETR. setdatasource (mcontext, video. geturiwithdrmcheck (); RETR. setmode (mediametadataretriever. mode_capture_frame_only); bitmap Bm = RETR. captureframe (); int wvideo = BM. getwidth (); int hvideo = BM. getheight ();
I think this code is useful. I will record it here.