vlc 安卓版开发_基于VLC框架的Android视频播放器Demo

前言

在 从零开始,手把手教你如何在Ubuntu下编译VLC-Android源码 文章中为大家讲解了如何在Ubuntu环境下编译VLC-Android源码,这篇文章就为大家讲解如何使用编译好的 libvlc-3.0.0.aar 包来编写一个视频播放器项目源代码

本博客同步发布于XueLong的博客

代码实现

build.gradle 中配置使用 libvlc-3.0.0.aar 包

//---1、---

repositories{

flatDir{

dirs 'libs'

}

}

dependencies {

...

//---2、---

compile(name:'libvlc-3.0.0',ext:'aar')

}

界面布局很简单,一个FrameLayout中嵌套一个SurfaceView。

布局实现

android:id="@+id/ll_vlc"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/surface_view"

android:layout_width="match_parent"

android:layout_height="match_parent"/>

Activity或者Fragment要实现 IVLCVout.OnNewVideoLayoutListener 接口,实现 onNewVideoLayout方法,在 onNewVideoLayout 方法中根据屏幕大小来动态控制视频播放显示区域大小。

代码实现

public class VLCActivity extends BaseActivityForFullScreen implements IVLCVout.OnNewVideoLayoutListener {

private static final String SAMPLE_URL = "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v";

SurfaceView surfaceView = null;

FrameLayout frameLayout = null;

LibVLC mLibVLC = null;

MediaPlayer mMediaPlayer = null;

IVLCVout mIVLCVout = null;

View.OnLayoutChangeListener onLayoutChangeListener = null;

Handler handler = new Handler();

int mVideoHeight = 0;

int mVideoWidth = 0;

int mVideoVisibleHeight = 0;

int mVideoVisibleWidth = 0;

int mVideoSarNum = 0;

int mVideoSarDen = 0;

static final int SURFACE_BEST_FIT = 0;

static final int SURFACE_FIT_SCREEN = 1;

static final int SURFACE_FILL = 2;

static final int SURFACE_16_9 = 3;

stat

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值