我开发了一个播放视频的应用程序..播放视频的代码在这里..
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 视频时。它以全屏方式显示,字符出现挤压。我需要使用遮罩(视频上方和下方两个水平黑条)以宽屏格式播放。有什么建议吗?