【发布时间】:2011-01-29 04:00:01
【问题描述】:
我正在使用 MediaPlayer 和 SurfaceView 播放本地视频文件。 SurfaceView 是活动中的唯一控件,而我的视频文件是 QVGA 或其他。问题是视频被拉伸了,我怎样才能以原始大小播放视频,例如qvga,剩余区域为黑色。
从迭代中,
当我在 XML 中强制设置 Surfaceview 的 layout_height/width 时,视频显示正常。
surface_holder.setFixedSize(w,h) 无效,mp.setdisplay() 也无效。
请在此指导。
更新
XML 文件
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SurfaceView
android:id="@+id/surface"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dip" />
</framelayout>
MediaPlayer 的使用方法见以下链接
提前致谢。
【问题讨论】:
标签: android media-player