Rotating the actual videobuffer in Videoview

风格不统一 提交于 2019-12-10 13:06:00

问题


I am currently developing an App specifically for android's GoogleTV devices where using or forcing the orientation of the app to anything other than landscape is not enabled, and will not be enabled in the future from what i have figured, in actuality the app simply crashes upon trying to run setRequestedOrientation();

Videoviews inherit the positional properties from normal views, Stuff like SetX, SetY and namely SetRotation.

You can set the videoview's rotation to 90 degrees, but the actual videobuffer will NOT rotate. I've tried everything from using the old mediaplayer > surfaceview.getHolder().lockcanvas().rotate(degrees) in every way imaginable, to overwriting the onDraw method of a custom videoview that extends the normal class, none of which i could get working successfully.

In a nutshell, How can i rotate the ACTUAL video within the videoview, without changing the device's orientation? if you have a working example of a rotated videoview with the contents of it also rotated please do explain how you got it working.

Thanks in advance.

I'd like you to note that we're developing for android 3.1 and also that everything so far has been coded dynamically, all imageviews and videoview are created through code, only the specific Layouts that we use for Z indexing items have been defined in the layout.xml file.


回答1:


VideoView does not support rotation of video even if composition matrix is set correctly and rotation attribute is used.

What you can do is to use TextureView and set its attribute rotation="90" (for example). It then will rotate the frames but the aspect ratio is something that you need to handle your self. In order to do so you can use textTureView.setScaleX((screenHeight * 1.0f) / screenWidth)

More details are here: Rotating an android VideoView



来源:https://stackoverflow.com/questions/8327774/rotating-the-actual-videobuffer-in-videoview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!