Coder Social home page Coder Social logo

zongyaoliu / dkplayer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from doikki/dkvideoplayer

0.0 2.0 0.0 26.35 MB

基于IjkPlayer的视频播放器,支持直播点播,悬浮窗播放,广告播放,边播边缓存;支持重力感应自动全屏;完美实现ListView和RecyclerView列表播放;模仿抖音效果demo

License: Apache License 2.0

Java 100.00%

dkplayer's Introduction

DKPlayer

A video player based on IjkPlayer.

API

特性

  • 支持滑动调节进度,声音、亮度。
  • 支持双击播放、暂停。
  • 支持重力感应自动进入/退出全屏。
  • 支持边播边缓存,使用了AndroidVideoCache
  • 完美实现列表播放(RecyclerView和ListView)。
  • 支持列表自动播放。
  • 支持列表小窗悬浮播放。
  • 支持封面。
  • 支持锁定/解锁全屏。
  • 支持调整显示比例:默认、原始大小、16:9、4:3、铺满屏幕。
  • 暂停时前后台切换不黑屏
  • 支持IJKPlayer和MediaPlayer切换。
  • 支持Https协议。
  • 支持连续播放一个列表的视频。
  • 支持悬浮窗播放。
  • 支持广告播放。
  • 支持弹幕,使用了DanmakuFlameMaster
  • 抖音demo。

demo下载

使用

1.添加类库

gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    # required, enough for most devices.
    implementation 'com.github.dueeeke.dkplayer:dkplayer-java:2.1.1'
    implementation 'com.github.dueeeke.dkplayer:dkplayer-armv7a:2.1.1'

    # Other ABIs: optional
    implementation 'com.github.dueeeke.dkplayer:dkplayer-armv5:2.1.1'
    implementation 'com.github.dueeeke.dkplayer:dkplayer-arm64:2.1.1'
    implementation 'com.github.dueeeke.dkplayer:dkplayer-x86:2.1.1'
    implementation 'com.github.dueeeke.dkplayer:dkplayer-x86_64:2.1.1'
}

或者将library下载并导入项目中使用

2.添加布局

<com.dueeeke.videoplayer.player.IjkVideoView
        android:id="@+id/player"
        android:layout_width="match_parent"
        android:layout_height="300dp" />

3.设置视频地址、标题、Controller等

ijkVideoView.setUrl(URL_VOD); //设置视频地址
ijkVideoView.setTitle("网易公开课-如何掌控你的自由时间"); //设置视频标题
StandardVideoController controller = new StandardVideoController(this);
ijkVideoView.setVideoController(controller); //设置控制器,如需定制可继承BaseVideoController
ijkVideoView.start(); //开始播放,不调用则不自动播放

//高级设置(可选,须在start()之前调用方可生效)
PlayerConfig playerConfig = new PlayerConfig.Builder()
        .enableCache() //启用边播边缓存功能
        .autoRotate() //启用重力感应自动进入/退出全屏功能
        .useAndroidMediaPlayer()//启动AndroidMediaPlayer,不调用此方法默认使用IjkPlayer
        .useSurfaceView() //启用SurfaceView显示视频,不调用默认使用TextureView
        .build();
ijkVideoView.setPlayerConfig(playerConfig);

4.在Activity

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

    @Override
    protected void onResume() {
        super.onResume();
        ijkVideoView.resume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ijkVideoView.release();
    }


    @Override
    public void onBackPressed() {
        if (!ijkVideoView.onBackPressed()) {
            super.onBackPressed();
        }
    }

5.在AndroidManifest.xml

<activity
    android:name=".PlayerActivity"
    android:configChanges="orientation|screenSize|keyboardHidden"
    android:screenOrientation="portrait" /> <!-- or android:screenOrientation="landscape"-->

其他API的用法参照demo

截图

混淆

-keep class tv.danmaku.ijk.** { *; }
-dontwarn tv.danmaku.ijk.**
-keep class com.dueeeke.videoplayer.** { *; }
-dontwarn com.dueeeke.videoplayer.**

License

Copyright (c) 2017 dueeeke

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.

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.