Giter Site home page Giter Site logo

moneyshih / ijkplayer-android Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dynckathline/ijkplayer-android

0.0 2.0 0.0 51.55 MB

直接使用ijkplayer,基本上无改动,ijkplayer升级可以直接拷贝过来然后删除少许代码即可

Java 100.00%

ijkplayer-android's Introduction

QQ交流群:611902811,有兴趣的可以交流

IJKPlayer-android

优势: 对ijkplayer的抽取值删除了IjkVideoView.java类中几个无关紧要的变量和方法,其他与ijkplayer本身一摸一样。这样ijkplayer升级后,直接拷贝过来,无需任何改动。 对ijkplayer中的EXOplayer模块一直处于r1.x.x版本升级到r.2.x.x版本。同时ijkplayer-exo2中的IjkExoMediaPlayer.java我增加了RTMP的支持,播放速率,其他的暂时还没有,如果还想增加,请对照EXOplayer进行增加即可。

效果图

image

如果点击下载不了可以从以下找到它
image

首先打开/Bilibili/ijkplayer,利用git命令

git clone https://github.com/Bilibili/ijkplayer.git

然后在你现有的项目里新建一个module,如图所示:
image
然后从Bilibili/ijkplayer的项目中拷贝出我们需要的文件,如图所示:
image image
不要忘了在module的build.gradle中依赖所需的依赖

compile 'tv.danmaku.ijk.media:ijkplayer-java:0.8.4'
compile 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.4'
compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.4'

如果想支持EXOplayer r2.x.x版本依赖

compile 'org.dync.kathline:ijkplayer-exo2:0.8.4'
//有冲突可以使用下面的去除重复
compile ('org.dync.kathline:ijkplayer-exo2:0.8.4'){
   exclude group: 'tv.danmaku.ijk.media',
          module: 'ijkplayer-java'
}

image
做完之后,IjkVideoView.java文件会出错,但是我们只要删除这些报错的变量和方法就好了,做到这步之后,我们开始播放了。
此外我们可以给IjkVideoView.java增加几个额外的方法。这里我提供我的:

    ///////////////////////////////额外增加的方法//////////////////////////////////

    /**
     * 参考{@link IRenderView#AR_ASPECT_FIT_PARENT}、{@link IRenderView#AR_ASPECT_FILL_PARENT}、{@link IRenderView#AR_ASPECT_WRAP_CONTENT}
     * {@link IRenderView#AR_16_9_FIT_PARENT}、{@link IRenderView#AR_4_3_FIT_PARENT}
     * 设置播放区域拉伸类型
     */
    public void setAspectRatio(int aspectRatio) {
        for (int i = 0; i < s_allAspectRatio.length; i++) {
            if (s_allAspectRatio[i] == aspectRatio) {
                mCurrentAspectRatioIndex = i;
                if (mRenderView != null) {
                    mRenderView.setAspectRatio(mCurrentAspectRatio);
                }
                break;
            }
        }
    }

    /**
     * 设置旋转角度
     */
    public void setPlayerRotation(int rotation) {
        mVideoRotationDegree = rotation;
        if (mRenderView != null) {
            mRenderView.setVideoRotation(mVideoRotationDegree);
        }
    }

    /**
     * 设置播放速率,这里仅对支持IjkMediaPlayer播放器
     *
     * @param rate  0.2~2.0之间
     */
    public void setPlayRate(@FloatRange(from=0.2, to=2.0)float rate) {
        if(mMediaPlayer instanceof IjkMediaPlayer){
            ((IjkMediaPlayer)mMediaPlayer).setSpeed(rate);
        }else {
            Toast.makeText(getContext(), getResources().getString(R.string.TrackType_unknown), Toast.LENGTH_SHORT).show();
        }
    }

其中setPlayRate()方法需要在createPlayer()方法中设置如下代码:

ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "soundtouch", 1);

这几句代码的含义是设置倍速后播放音调不会在android6.0以下变音
image
到了这一步差不多完成了,但是android4.4~android6.0之间没有沉浸式。这里用到了我的另一个项目ChangeStatusColor-Android了。使用方法

大功告成了。\(^o^)/~ 如果不想麻烦可以clone我的IJKPlayer-android项目下来,直接导入我的module。

ijkplayer-android's People

Contributors

dynckathline avatar

Watchers

James Cloos avatar  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.