【发布时间】:2012-11-27 23:27:56
【问题描述】:
我正在像这样在运行时创建一个 VideoView:
@Override
public View getUIElement(){
if(vv==null){
this.vv = new VideoView(this.getContext());
vv.setVideoURI(Uri.parse(this.url));
mc = new MediaController(this.getContext());
vv.setMediaController(mc);
}
return vv;
}
然后我将此 VideoView 添加到 LinearLayout 我称之为:
public void initVideo(){
mc.show();
vv.setBackgroundColor(Color.TRANSPARENT);
vv.requestFocus();
vv.start();
Log.v("Video",vv.toString());
}
此代码在 Froyo (2.2) 和 Gingerbread (2.3.5) 上完美运行,但在 ICS (4.0) 和 JB(4.1) 上没有任何反应 - VideoView 在父视图中甚至不可见。你有什么想法为什么? 在 Uri.parse() 中,我将 url 传递给 mp4 文件。
--编辑 我忘了说,在 ICS ang JB 的 LogCat 中,甚至没有调用 MediaPlayer(在 Froyo 和 Gingerbread 中,有一些由 MediaPlayer 类生成的信息)。
【问题讨论】:
-
[已解决] - 问题是正确的 LayoutParameters。在 API
-
能否请您将代码行放在您为 videoview 设置布局参数的位置。
标签: android android-4.0-ice-cream-sandwich android-videoview