我开发的应用程序,用于播放视频..播放视频是这里的代码..安卓播放宽屏视频
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.videoview);
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
mVideoView = (VideoView)findViewById(R.id.videoview);
path=filename;
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(
ViewVideo.this,
"Please edit VideoViewDemo Activity, and set path"
+ " variable to your media file URL/path",
Toast.LENGTH_LONG).show();
} else {
mVideoView.setVideoPath(path);
mc = new MediaController(this);
mVideoView.setMediaController(mc);
mVideoView.requestFocus();
mVideoView.bringToFront();
mVideoView.start();
}
}
下面是XML代码
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="fill_parent">
</VideoView>
</RelativeLayout>
的问题是,当我尝试播放宽屏幕16:9视频。它在全屏显示它,字符出现挤压。我需要用宽屏格式(视频上方和下方的两个水平黑条)播放。 有什么建议吗?
您是否也可以发布您的XML布局? – theisenp
我编辑了包含xml的代码..你能否帮我在这里.. – Farhan
可能你需要为VideoView设置布局参数。我已经为其中一个stackoverflow帖子上的视频回放放置了一个Activty的代码。可以参考http://stackoverflow.com/questions/6977382/videoview-in-eclipse-not-playing-on-phone/6977770#6977770 – Shash316