android:播放宽屏视频
我开发了一个用于播放视频的应用程序..播放视频的代码在这里..
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视频时。它在全屏上显示它并且角色看起来被挤压。我需要以带有遮罩的宽屏格式播放(视频上方和下方有两个水平黑条)。 请问有什么建议吗?
I developed an application for playing video.. the code for playing video is here..
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();
}
}
Here is the xml code
<?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>
The problem is that when I try to play a widescreen 16:9 video. It shows it on fullscreen and the characters appear squeezed. I need to play in widescreen format with mattes (two horizontal black bars above and below the video)..
Any suggestions please ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是相关问题 。
看起来您正在通过使用强制视频与屏幕的所有四个边对齐,
这会影响视频的宽高比。相反,尝试将其放入 LinearLayout 中:
Here's a related question.
It seems like you are forcing the video to align with all four sides of the screen by using
This is throwing off the aspect ratio of the video. Instead try putting it in a LinearLayout:
尝试在垂直线性布局中使用 MediaViewer。
像这样的东西(在我的脑海中,所以不要隐含地相信它):
这应该填满屏幕垂直区域的 2/3。
根据需要调整weightSum和layout_weight。
希望这有帮助!
Try using the MediaViewer in a vertical linearLayout.
Something like this (off the top of my head, so don't trust it implicitly):
This should fill up 2/3 of the vertical area of the screen.
Adjust weightSum and layout_weight as desired.
Hope this helps!