安卓:媒体播放器:如何使用SurfaceView或媒体播放器在正确的大小播放视频 [英] Android: Mediaplayer: How to use SurfaceView or mediaplayer to play video in correct size

查看:141
本文介绍了安卓:媒体播放器:如何使用SurfaceView或媒体播放器在正确的大小播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我玩用的MediaPlayer和SurfaceView本地视频文件。 SurfaceView是活动的唯一的控制,而我的视频文件QVGA或其他。问题是,视频是越来越捉襟见肘,在其原来的大小,例如如何播放视频QVGA剩余面积的黑色。

I am playing local video file using MediaPlayer and SurfaceView. SurfaceView is the only control in activity, while my video files are QVGA or other. Problem is that video is getting stretched, How can i play video in its original size e.g. qvga with remaining area black.

从迭代,

当我是强行设置layout_height Surfaceview的XML /宽,视频显示的罚款。 surface_holder.setFixedSize(W,H)没有效果,既不mp.setdisplay()。

When i am forcefully sets layout_height/width of Surfaceview in XML, video displayed fine. surface_holder.setFixedSize(w,h) has no effect, neither mp.setdisplay().

请在本指南。

更新

XML flie

<?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的使用量是按下面的链接

MediaPlayer usage is as per following link

<一个href="http://davanum.word$p$pss.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/">http://davanum.word$p$pss.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/

在此先感谢。

推荐答案

在XML中的SurfaceView您使用WRAP_CONTENT?这应该可以解决你的问题,如果没有。您可能需要粘贴多一点code作进一步调查,如果不解决您的问题。

On your SurfaceView in XML are you using wrap_content ? This should fix your problem if not. You may need to paste a little more code for further investigation if that doesn't fix your problem.

更改您的视图面宽度WRAP_CONTENT为好。

Change your surface view width to wrap_content as well.

这篇关于安卓:媒体播放器:如何使用SurfaceView或媒体播放器在正确的大小播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆