Code Monkey home page Code Monkey logo

playerbase's Introduction

image

PlayerBase-Core

Download API

ExoPlayerPkg

Download API

IjkPlayerPkg

Download API

博文地址Android播放器基础封装库PlayerBase

使用及依赖-已适配AndroidX

需要的权限,如果targetSDK版本在Android M以上的,请注意运行时权限的处理。

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

只使用MediaPlayer

dependencies {
  
  //该依赖仅包含MediaPlayer解码
  implementation 'com.kk.taurus.playerbase:playerbase:3.4.1'
  
}

使用ExoPlayer + MediaPlayer

dependencies {
 
  //该依赖包含exoplayer解码和MediaPlayer解码
  //注意exoplayer的最小支持SDK版本为16
  implementation 'cn.jiajunhui:exoplayer:341_2122_017'
  
}

使用ijkplayer + MediaPlayer

dependencies {
  
  //该依赖包含ijkplayer解码和MediaPlayer解码
  implementation 'cn.jiajunhui:ijkplayer:341_088_012'
  //ijk官方的解码库依赖,较少格式版本且不支持HTTPS。
  implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
  # Other ABIs: optional
  implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
  implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
  implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
  implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
  
}

使用ijkplayer + ExoPlayer + MediaPlayer

dependencies {
  
  //该依赖包含exoplayer解码和MediaPlayer解码
  //注意exoplayer的最小支持SDK版本为16
  implementation 'cn.jiajunhui:exoplayer:340_2120_016'

  //该依赖包含ijkplayer解码和MediaPlayer解码
  implementation 'cn.jiajunhui:ijkplayer:340_088_011'
  //ijk官方的解码库依赖,较少格式版本且不支持HTTPS。
  implementation 'tv.danmaku.ijk.media:ijkplayer-armv7a:0.8.8'
  # Other ABIs: optional
  implementation 'tv.danmaku.ijk.media:ijkplayer-armv5:0.8.8'
  implementation 'tv.danmaku.ijk.media:ijkplayer-arm64:0.8.8'
  implementation 'tv.danmaku.ijk.media:ijkplayer-x86:0.8.8'
  implementation 'tv.danmaku.ijk.media:ijkplayer-x86_64:0.8.8'
  
}

如果您添加依赖exoplayer的库,需要在gradle中增加如下配置。

buildTypes {

    //...
    
    compileOptions{
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

代码混淆时,请在proguard中添加如下保护

-keep public class * extends android.view.View{*;}

-keep public class * implements com.kk.taurus.playerbase.player.IPlayer{*;}

初始化

public class App extends Application {

    @Override
    public void onCreate() {
        //...
        
        //如果您想使用默认的网络状态事件生产者,请添加此行配置。
        //并需要添加权限 android.permission.ACCESS_NETWORK_STATE
        PlayerConfig.setUseDefaultNetworkEventProducer(true);
        //初始化库
        PlayerLibrary.init(this);
        
        //-------------------------------------------
        
        //如果添加了'cn.jiajunhui:exoplayer:xxxx'该依赖
        ExoMediaPlayer.init(this);
        
        //如果添加了'cn.jiajunhui:ijkplayer:xxxx'该依赖
        IjkPlayer.init(this);
        
        
        //播放记录的配置
        //开启播放记录
        PlayerConfig.playRecord(true);
        PlayRecordManager.setRecordConfig(
                        new PlayRecordManager.RecordConfig.Builder()
                                .setMaxRecordCount(100)
                                //.setRecordKeyProvider()
                                //.setOnRecordCallBack()
                                .build());
        
    }
    
}

交流

联系方式:[email protected]

QQ群:600201778

License

Copyright 2017 jiajunhui<[email protected]>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0
   
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

playerbase's People

Contributors

jiajunhui avatar nukc 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.