vitamio5.x的简单使用

vitamio5.x的简单使用

  这几天有个需求需要播放视频,Android的VideoView虽然用起来方便,但是支持的格式比较少,而且可拓展性差一些,遂想到了vitamio。
  vitamio官网的文档写的比较随意,嗯,随意到比X萌,X信,XX宝的文档还随意,于是乎,还是自己研究一下DEMO吧。
  首先在官网下载一个vitamio5.x的zip,官网说4.x的版本有一些不可描述的隐患(-_-),下载好后找到vitamio,在AndroidStudio下开发的话推荐将vitamio直接添加到module下,vitamio的源码也不小,第一次运行可能会遇到找不到控件,重启工程或者多编译几次即可解决。
  核心控件是io.vov.vitamio.widget.VideoView,直接将其代替原生的videoview控件,书写布局。5.x的版本与以前不同,查了网上的一些资料,4.x的居多,初始化ViedoView需要 调用

Vitamio.isInitialized(getApplicationContext());
  初始化控制器需要使用io.vov.vitamio.widget.MediaController

 mMediaController = new io.vov.vitamio.widget.MediaController(this);//实例化控制器
  接着需要设置一个path,存放播放视频的path,接着使用即可

  mVideoView.setVideoPath(path);
        mVideoView.setMediaController(mMediaController);

        //这里可选
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                mediaPlayer.setPlaybackSpeed(1.0f);
            }
        });
  到此,视频就可以播放了,支持了绝大多数流行的视频格式,需要注意的是使用vitamio需要android4.0以上,如果项目需要兼容4.0以下,需要考虑一些兼容问题了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
Vitamio =============== Vitamio is an open multimedia framework for Android and iOS, with full and real hardware accelerated decoder and renderer. New features ------------ Only few important features are listed here, we have fix many bugs and may introduce some new bugs. 1. The latest FFmpeg 2.0 git version, which should fix most playback issues, or bring some issues. 2. Support most FFmpeg AVOptions, which enables custom HTTP headers support. 3. Support more hardwares, e.g. X86 or MIPS. 4. Improve streaming, especially support adaptive bitrate streaming, you need open manually. 5. OpenSSL included, so some SSL related protocols, such as https, tls, rtmps, rtmpts, are supported. 6. Playback speed control from 0.5x to 2.0x. 7. Audio amplify to 2x volume. 8. Improved subtitle support, including external bitmap subtitles. 9. Cache online video to local storage and can be reused until you delete the cache file. 10. More MediaPlayer API, e.g. `getMetadata`, `getVideoTrack`. 11. The full Java code is open to all developers, modify and contribute is welcome. 12. Support RGBA\_8888 rendering, spport switching RGB\_565 or RGBA\_8888 to video rendering. 13. Enhance the hardware decoding in Android 16+. 14. Support ARMV6 CPU, may have some bugs. How to use ---------- please see [the website](https://github.com/yixia/VitamioBundle/wiki) License ------- Please see [License](http://www.vitamio.org/en/License) ## Google+ Vitamio Developers Community on Google+ [http://goo.gl/fhCDTD](http://goo.gl/fhCDTD)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值