Giter VIP home page Giter VIP logo

jenly1314 / kingplayer Goto Github PK

View Code? Open in Web Editor NEW
61.0 6.0 22.0 54.47 MB

:clapper: 一个专注于 Android 视频播放器的基础库,无缝切换内核。(IjkPlayer、ExoPlayer、VlcPlayer、MediaPlayer)

Home Page: https://jenly1314.github.io/projects/KingPlayer

License: MIT License

Java 91.78% Kotlin 8.22%
ijkplayer player kingplayer mediaplayer video-player pldroidplayer vlc-player vlcplayer exoplayer vlc-libvlc videoplayer videoview sysplayer android

kingplayer's Introduction

KingPlayer

Download JCenter JitPack CI CircleCI API License

KingPlayer 一个专注于 Android 视频播放器(IjkPlayer、ExoPlayer、VlcPlayer、SysPlayer)的基础库,无缝切换内核。

功能说明

  • 主要播放相关核心功能
  • 播放器无缝切换
    • MediaPlayer封装实现(SysPlayer)
    • IjkPlayer封装实现
    • ExoPlayer封装实现
    • vlc-android封装实现
  • 控制图层相关
    • 待补充...

Gif 展示

Image

你也可以直接下载 演示App 体验效果

引入

Gradle:

  1. 在Project的 build.gradlesetting.gradle 中添加远程仓库

    repositories {
      //...
      mavenCentral()
      maven { url 'https://jitpack.io' }
    }
  2. 在Module的 build.gradle 里面添加引入依赖项

    使用 SysPlayer (Android自带的MediaPlayer)

    //KingPlayer基础库,内置SysPlayer
    implementation 'com.github.jenly1314.KingPlayer:king-player:1.0.0-beta1'

    使用 IjkPlayer

    //KingPlayer基础库(必须)
    implementation 'com.github.jenly1314.KingPlayer:king-player:1.0.0-beta1'
    //IjkPlayer
    implementation 'com.github.jenly1314.KingPlayer:ijk-player:1.0.0-beta1'
    
    // 根据您的需求选择ijk模式的so
    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

    //KingPlayer基础库(必须)
    implementation 'com.github.jenly1314.KingPlayer:king-player:1.0.0-beta1'
    //ExoPlayer
    implementation 'com.github.jenly1314.KingPlayer:exo-player:1.0.0-beta1'

    使用 VlcPlayer

    //KingPlayer基础库(必须)
    implementation 'com.github.jenly1314.KingPlayer:king-player:1.0.0-beta1'
    //VlcPlayer
    implementation 'com.github.jenly1314.KingPlayer:vlc-player:1.0.0-beta1'

使用

布局示例

    <com.king.player.kingplayer.view.VideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

代码示例

        //初始化一个视频播放器(IjkPlayer、ExoPlayer、VlcPlayer、SysPlayer)
        videoView.player = IjkPlayer(context)
        //初始化数据源
        val dataSource = DataSource(url)
        videoView.setDataSource(dataSource)

        videoView.setOnSurfaceListener(object : VideoView.OnSurfaceListener {
            override fun onSurfaceCreated(surface: Surface, width: Int, height: Int) {
                LogUtils.d("onSurfaceCreated: $width * $height")
                videoView.start()
            }

            override fun onSurfaceSizeChanged(surface: Surface, width: Int, height: Int) {
                LogUtils.d("onSurfaceSizeChanged: $width * $height")
            }

            override fun onSurfaceDestroyed(surface: Surface) {
                LogUtils.d("onSurfaceDestroyed")
            }

        })

        //缓冲更新监听
        videoView.setOnBufferingUpdateListener {
            LogUtils.d("buffering: $it")
        }
        //播放事件监听
        videoView.setOnPlayerEventListener { event, bundle ->

        }
        //错误事件监听
        videoView.setOnErrorListener { event, bundle ->

        }
        

        
        //------------ 控制相关
        //开始
        videoView.start()
        //暂停
        videoView.pause()
        //进度调整到指定位置
        videoView.seekTo(pos)
        //停止
        videoView.stop()
        //释放
        videoView.release()
        //重置
        videoView.reset()

更多使用详情,请查看app中的源码使用示例或直接查看API帮助文档

其他

需使用JDK8+编译,在你项目中的build.gradle的android{}中添加配置:

compileOptions {
    targetCompatibility JavaVersion.VERSION_1_8
    sourceCompatibility JavaVersion.VERSION_1_8
}

版本记录

v1.0.0-beta1:2020-12-28

  • KingPlayer初始版本

感谢

ijkPlayer

ExoPlayer

vlc-android

MediaPlayer

赞赏

如果您喜欢KingPlayer,或感觉KingPlayer帮助到了您,可以点右上角“Star”支持一下,您的支持就是我的动力,谢谢 😃

您也可以扫描下面的二维码,请作者喝杯咖啡 ☕

关于我

我的博客 GitHub Gitee CSDN 博客园
Jenly's Blog jenly1314 jenly1314 jenly121 jenly

联系我

微信公众号 Gmail邮箱 QQ邮箱 QQ群 QQ群
Jenly666 jenly1314 jenly1314 20867961 64020761

kingplayer's People

Contributors

jenly1314 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kingplayer's Issues

TV断上下换频道怎么恢复

TV断上下换频道怎么恢复,我按照demo的写法第一次播放没问题,第二次依次调用release()、reset()、setPlayer()、setDataSource()、setOnSurfaceListener()怎么就不能播放了?

Some advices

Please implement setOnPreparedListener
then developers don't need to check PlayerEventListener

example for ExoPlayer

image

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.