setRotation后,Android VideoView不打() [英] Android VideoView not playing after setRotation()

查看:1259
本文介绍了setRotation后,Android VideoView不打()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现,调用一个VideoView setRotation(),即VideoView不再玩了。没有错误的是Android运行时抛出,而VideoView正确决定其产量尺寸,但只显示为纯黑色框。

I've found that after calling setRotation() on a VideoView, that VideoView no longer plays. No errors are thrown by the Android runtime, and the VideoView correctly determines its crop dimensions but only shows as a solid black box.

这是一个已知的限制?如果是的话是有另一种方式来旋转VideoViews?我使用API​​级16。

Is this a known limitation? If so is there another way to rotate VideoViews? I'm using API level 16.

编辑:视频播放音频,但没有视频。也许根本SurfaceView没有被重新定位?

The video plays audio, but no video. Perhaps the underlying SurfaceView isn't being repositioned?

推荐答案

要回答自己的情况下,它可以帮助别人后面,这是VideoView的已知限制。从这个Android图形的博客文章

To answer myself in case it helps somebody later, this is a known limitation of VideoView. Quote from this Android graphics blog post:

由于一个SurfaceView的内容并不住在应用程序的窗口,它不能改变(移动,缩放,旋转)有效。这使得难以使用SurfaceView一个ListView或滚动型的内部。 SurfaceView也不能与UI工具包的某些功能,如褪色边缘或View.setAlpha()正确交互。

Because a SurfaceView’s content does not live in the application’s window, it cannot be transformed (moved, scaled, rotated) efficiently. This makes it difficult to use a SurfaceView inside a ListView or a ScrollView. SurfaceView also cannot interact properly with some features of the UI toolkit such as fading edges or View.setAlpha().

我能找到的唯一解决办法是用新推出的更换VideoView TextureView ,这是只有在API级别14及更高版本。从我读它不是目前在兼容性库可用。 这个问题有如何使用TextureView播放视频的例子,它是pretty容易和你失去的是一个VideoView一个包装的MediaPlayer为你带来的便利。

The only solution I could find was to replace the VideoView with the newly-introduced TextureView, which is only available in API level 14 and above. From what I read it is not currently available in the compatibility library. This question has an example of how to use a TextureView to play video, it's pretty easy and all you lose is the convenience of a VideoView wrapping a MediaPlayer for you.

这篇关于setRotation后,Android VideoView不打()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆