ArtVideoPlayer

Introduction: 这是一个灵活的视频播放器。支持全屏,小屏播放;内部支持 RecyclerView,ListView 中播放;自定义 UI ;APP 内全局播放;静音;循环播放
More: Author   ReportBugs   
Tags:

English | 简体中文

GitHub top language Hex.pm GitHub release (latest by date)

简介

Kotlin 实现的视频播放器,将 MediaPlayer 与 VideoView 解耦合,支持切换播放器内核(如 ExoPlayer 和 ijkPlayer),支持自定义控制视图,提供 MediaPlayerManager 实现全屏模式,小屏幕模式等。

查看详细文档

特点

  • ijkPlayer 支持
  • ExoPlayer 支持
  • 全屏,小屏播放
  • 完全自定义 UI
  • 静音
  • 循环播放
  • 倍速播放(IjkPlayer 支持)
  • 多播放器同时播放
  • Raw/Assets,本地视频文件播放支持
  • Activity 生命周期感知,实现了 onPause 暂停播放,onDestory 停止播放并释放资源
  • 手势操作支持(小窗:单指拖动,双指缩放;全屏:音量,亮度,快进)
  • 重力感应支持

开始使用

核心依赖

implementation 'org.salient.artvideoplayer:artplayer-core:1.1.0'

选择使用 ExoPlayer

implementation "org.salient.artvideoplayer:artplayer-exo:1.1.0"

选择使用 IjkPlayer

implementation 'org.salient.artvideoplayer:artplayer-ijk:1.1.0'
implementation "org.salient.artvideoplayer:artplayer-armv7a:1.1.0"

需要支持不同的 cpu 架构

implementation "org.salient.artvideoplayer:artplayer-armv5:1.1.0"
implementation "org.salient.artvideoplayer:artplayer-x86:1.1.0"
//下面两个需要 minSdk version >= 21
implementation "org.salient.artvideoplayer:artplayer-arm64:1.1.0"
implementation "org.salient.artvideoplayer:artplayer-x86_64:1.1.0"

使用方法

kotlin

import org.salient.artplayer.VideoView

val videoView = VideoView(context)
videoView.mediaPlayer = SystemMediaPlayer().apply{
    setDataSource(context, Uri.parse("http://vfx.mtime.cn/Video/2018/07/06/mp4/180706094003288023.mp4"))
}
videoView.prepare()

xml

<org.salient.artplayer.VideoView
    android:id="@+id/video_view"
    android:layout_width="match_parent"
    android:layout_height="200dp"/>

AndroidManifest.xml

<activity
    android:name=".YourActivity"
    android:configChanges="orientation|screenSize" /> <!-- required -->

Activity

//拦截全屏时的返回事件
override fun onBackPressed() {
    if (MediaPlayerManager.blockBackPress(this)) {
        return
    }
    super.onBackPressed()
}

设置封面

//绑定封面图片资源到 VideoView 的`cover`字段
Glide.with(context)
        .load("http://img5.mtime.cn/mg/2018/07/06/093947.51483272.jpg")
        .into(videoView.cover);

支持

构建环境

  • Kotlin 1.37.2
  • Java 1.8
  • Android Studio 3.6.0
  • Gradle 5.6.4
  • IjkPlayer 0.8.8
  • ExoPlayer 2.11.3

作者

联系方式

  • cv.stronger@gmail.com

License

   Copyright 2018 maiwenchang
   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.
Apps
About Me
GitHub: Trinea
Facebook: Dev Tools