vlc for android 不能全屏,或者画面不能铺满的问题。

做视频开发的时候,肯定会遇到,小窗口播放,然后支持全屏播放。

   我遇到的问题,有两个。

一:小窗口视频有黑边。就是还是没充满。

二:全屏画面也是铺不满,而且跟小窗口的画面大小是一样的。

要解决这些问题,先介绍一下要用到的vlc的三个接口

videoView1.getMediaPlayer().getVLCVout().setWindowSize(wsur, hour);//宽,高  播放窗口的大小

videoView1.getMediaPlayer().setAspectRatio(wsur+":"+hsur);//宽,高  画面大小
videoView1.getMediaPlayer().setScale(0);  画面以什么形式展示在控件上

这三个接口可以在横竖屏监听里面写如下图的横竖屏监听。

当竖屏的时候,就传入SurfaceView的大小,当全屏的时候,就传入屏幕的宽高。他会自适应的充满你的控件。另外需要注意的是

MediaPlayer().setScale(0);
setScale一定要设置为0,不然你改变控件的大小是没有用的,血的教训。为什么?  来看一下setScale方法的注释。
/**
 * Set the video scaling factor
 *
 * That is the ratio of the number of pixels on screen to the number of pixels in the original
 * decoded video in each dimension. Zero is a special value; it will adjust the video to the
 * output window/drawable (in windowed mode) or the entire screen.
 *
 * @param scale the scaling factor, or zero
 */
public void setScale(float scale) {
    nativeSetScale(scale);
}
是0的时候才会可以拉伸。
行了,上次写的过于鸡肋,现在完善了。很开心。


--------------------- 
作者:丑人_lh 
来源:CSDN 
原文:https://blog.csdn.net/qq_36477525/article/details/78621387 
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/Crystal_xing/article/details/83788609