MediaPlayer-Extended icon indicating copy to clipboard operation
MediaPlayer-Extended copied to clipboard

missing setVideoScalingMode

Open stmkjp opened this issue 7 years ago • 3 comments

Hi, thanks for the great library!

I'm trying to implement your mediaplayer library and it's good but i have one problem. ( put video on textureview using mediaplayer ) I'm currently building app using portrait only mode, and it's ok when I load landscape video (scaled and no distortion) - same as default mediaplayer, screenshot_1492074880

but when I load portrait video, aspect ratio not maintained screenshot_1492074888

android default mediaplayer has setVideoScalingMode(MediaPlayer.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING) method

but I can't find corresponding method in MediaPlayer-Extended library.

Is there any way to resolve this? Any help would be really appreciated!

Best, JP

stmkjp avatar Apr 13 '17 09:04 stmkjp

Yes, MPX does not implement the setVideoScalingMode API method.

To maintain the aspect ratio, you can extend the TextureView and override onMeasure like I am doing in the VideoView here, which always resizes the View to fit it's aspect ratio to the video frame. You can then position this view within a layout.

If you want cropping, then there is currently no other way than to also override onMeasure to maintain the aspect ratio and programmatically set the size of an enclosing layout to crop the video as desired.

Btw. it is recommended to use SurfaceView over TextureView because the latter draws much more power.

protyposis avatar Apr 22 '17 11:04 protyposis

this is stupid your view should handle it. what i now got from your lib is basically the same as the one from android. stretched video and nothing else. And no I do not plan to dig deeper into this thing just to find out its not possible.

devingDev avatar May 04 '18 17:05 devingDev

Thank you for this very productive and enlightening comment, and good luck with your future endeavors.

protyposis avatar May 04 '18 17:05 protyposis