Giter Club home page Giter Club logo

iplayer's Introduction

iPlayer

一、SDK基础功能

  • 支持网络地址、直播流、本地Assets和Raw音视频资源文件播放
  • 支持播放倍速、缩放模式、静音、镜像等功能设置
  • 支持自定义视频解码器、控制器、UI交互组件、视频画面渲染器
  • 支持多播放器同时播放
  • SDK默认控制器(局部UI交互可自定义)支持手势控制、付费试看等交互
  • 支持重力感应横竖屏旋转及开关设置
  • 支持任意位置启动Activity级别悬浮窗口播放
  • 支持任意位置启动全局悬浮窗口播放
  • 窗口播放器支持自动吸附悬停
  • 支持任意位置直接启动全屏播放
  • 支持连续播放视频列表
  • Demo:列表或组件之间无缝转场播放
  • Demo:全局悬浮窗播放转场跳转Activity
  • Demo:MediaPlayer、IjkPlayer、ExoPlayer三种解码器切换
  • Demo:仿抖音,支持视频缓存、秒播
  • Demo:弹幕交互
  • Demo:Android8.0+画中画示例

三、SDK集成

  • 建议集成前先下载apk体验,找到自己想要实现的功能模块,后续集成可参考demo源码。
1、项目根build.gradle配置
    allprojects {
        repositories {
            maven { url 'https://jitpack.io' }
        }
    }
2、模块build.gradle配置
    dependencies {
        //播放器(无UI交互)
        implementation 'com.github.hty527.iPlayer:iplayer:2.1.20'
        //UI交互组件,可根据需要使用
        implementation 'com.github.hty527.iPlayer:widget:2.1.20'

        //音视频预缓存+边播边存,根据需要使用
        //implementation 'com.github.hty527.iPlayer:cache:2.1.20'

        //ijk音视频解码器,根据需要使用
        //implementation 'com.github.hty527.iPlayer:ijk:2.1.20'
        //exo音视频解码器,根据需要使用
        //implementation 'com.github.hty527.iPlayer:exo:2.1.20'
        //选择exo音视频解码器时需引用
        //以下为必须项,SDK内部已引用,集成时无需引用
        //implementation 'com.google.android.exoplayer:exoplayer:2.18.1'//(必需)
        //implementation 'com.google.android.exoplayer:exoplayer-core:2.18.1'//核心功能(必需)
        //implementation "com.google.android.exoplayer:extension-rtmp:2.18.1"//rtmp直播流解码协议//(必需)
        //exo音视频解码器,以下为可选依赖,请根据需要实现
        //implementation 'com.google.android.exoplayer:exoplayer-dash:2.18.1'//支持DASH内容
        //implementation "com.google.android.exoplayer:exoplayer-hls:2.18.1"//支持HLS内容
        //implementation "com.google.android.exoplayer:exoplayer-rtsp:2.18.1"//rtsp直播流解码协议
    }
3、在需要播放视频的xml中添加如下代码,或在适合的位置new VideoPlayer()
    <com.android.iplayer.widget.VideoPlayer
        android:id="@+id/video_player"
        android:layout_width="match_parent"
        android:layout_height="200dp"/>
4、播放器准备及开始播放
    mVideoPlayer = (VideoPlayer) findViewById(R.id.video_player);
    mVideoPlayer.getLayoutParams().height= getResources().getDisplayMetrics().widthPixels * 9 /16;//固定播放器高度,或高度设置为:match_parent
    //使用SDK自带控制器+各UI交互组件
    VideoController controller = new VideoController(mVideoPlayer.getContext());//创建一个默认控制器
    mVideoPlayer.setController(controller);//将播放器绑定到控制器
    WidgetFactory.bindDefaultControls(controller);//一键使用默认UI交互组件绑定到控制器(需集成:implementation 'com.github.hty527.iPlayer:widget:lastversion')
    //设置视频标题(仅横屏状态可见)
    controller.setTitle("测试地址播放");
    //设置播放源
    mVideoPlayer.setDataSource("https://upload.dongfeng-nissan.com.cn/nissan/video/202204/4cfde6f0-bf80-11ec-95c3-214c38efbbc8.mp4");
    //异步开始准备播放
    mVideoPlayer.prepareAsync();
5、生命周期处理
    @Override
    protected void onResume() {
        super.onResume();
        mVideoPlayer.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mVideoPlayer.onPause();
    }

    @Override
    public void onBackPressed() {
        if(mVideoPlayer.isBackPressed()){
            super.onBackPressed();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mVideoPlayer.onDestroy();
    }
6、常用API、更换解码器、自定义解码器、UI交互组件和悬浮窗口播放等功能请阅读wiki

四、遇到问题

五、SDK及Demo部分功能预览

六、鸣谢

  • ijkplayer
  • ExoPlayer
  • AndroidVideoCache
  • Demo演示视频列表模块api使用的是开眼api,本项目只做学习使用。禁止任何人应用于任何商业用途,由此带来的法律风险由应用于商业用途的一方承担!

iplayer's People

Contributors

hty527 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.