/PlayerBase

The basic library of Android player will process complex business components. The access is simple。Android播放器基础库,专注于播放视图组件的高复用性和组件间的低耦合,轻松处理复杂业务。

Primary LanguageJavaApache License 2.0Apache-2.0

image

PlayerBase

PlayerBase-Core

maven-central PlayerBase-Core

PlayerBase-IjkPlayer

maven-central PlayerBase-IjkPlayer

introduction

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

使用及依赖

请求的权限

如果需要监听网络状态,则需要添加权限:

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

集成

使用 MediaPlayer + ExoPlayer

buildTypes {
    // ExoPlayer require Java8
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    // 包含 ExoPlayer & MediaPlayer 解码
    implementation "com.weicools:player-base:3.5.0"
}

使用 MediaPlayer + ExoPlayer + IjkPlayer

buildTypes {
    // ExoPlayer require Java8
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation "com.weicools:player-base:3.6.0"
    implementation "com.weicools:player-ijkplayer:3.6.0"
    // 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'
}

使用

初始化

public class App extends Application {

    @Override
    public void onCreate() {

        // Default plan id = 0 // Decoder = MediaPlayer
        PlayerConfig.addDecoderPlan(new DecoderPlan(PLAN_ID_EXO, ExoMediaPlayer.class.getName(), "ExoPlayer"));
        PlayerConfig.addDecoderPlan(new DecoderPlan(PLAN_ID_IJK, IjkPlayer.class.getName(), "IjkPlayer")); // if add ijk libs
        PlayerConfig.setDefaultPlanId(0); // Use MediaPlayer
        // PlayerConfig.setDefaultPlanId(PLAN_ID_EXO); // Use ExoPlayer
        // PlayerConfig.setDefaultPlanId(PLAN_ID_IJK); // Use IjkPlayer
        PlayerLibrary.init(this);

        // 下面的初始化方式可以简化解码器相关设置
        // ExoMediaPlayer.init(this);
        // IjkPlayer.init(this); // if add ijk libs

        // 如果您想使用默认的网络状态事件生产者,请添加此行配置。
        // 并需要添加权限 android.permission.ACCESS_NETWORK_STATE
        // PlayerConfig.setUseDefaultNetworkEventProducer(true);

        // 开启播放记录
        PlayerConfig.playRecord(true);
        PlayRecordManager.RecordConfig recordConfig = new PlayRecordManager.RecordConfig.Builder()
                .setMaxRecordCount(100)
                .build();
        PlayRecordManager.setRecordConfig(recordConfig);
    }
}

交流

联系方式:junhui_jia@163.com

QQ群:600201778

License

Copyright 2017 jiajunhui<junhui_jia@163.com>

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.