簡介
這是一個簡單好用的Androi視頻播放器。 MediaPlayer與VideoView完全分開,可以替換爲其他播放器內核,如ExoPlayer和ijkPlayer。 可以完全自定義播放器視圖,我們稱之爲控制面板。 此外,可以使用MediaPlayerManager來控制播放行爲,例如全屏模式,小屏幕模式以及RecyclerView中的智能匹配模式。
特點
- 全屏,小屏播放
- 內部支持RecyclerView中播放
- 自定義UI
- APP內全局播放
- 靜音
- 循環播放
- 手勢操作(小窗:單指拖動,雙指縮放;全屏:音量,亮度,快進)
- ijkPlayer支持
- ExoPlayer支持
- 重力感應支持
- Raw/Assets,本地視頻文件播放支持
預覽
下載
開始使用
build.gradle
dependencies {
// required
implementation 'org.salient.artvideoplayer:artplayer-java:0.6.0'
// Default control panel: optional
implementation 'org.salient.artvideoplayer:artplayer-ui:0.6.0'
//ijkPlayer: optional
implementation 'org.salient.artvideoplayer:artplayer-ijk:0.6.0'
implementation "org.salient.artvideoplayer:artplayer-armv7a:0.6.0"
//Other ABIs: optional
implementation "org.salient.artvideoplayer:artplayer-armv5:0.6.0"
implementation "org.salient.artvideoplayer:artplayer-x86:0.6.0"
// Other ABIs: optional (minSdk version >= 21)
implementation "org.salient.artvideoplayer:artplayer-arm64:0.6.0"
implementation "org.salient.artvideoplayer:artplayer-x86_64:0.6.0"
//ExoPlayer2 : optional
implementation "org.salient.artvideoplayer:artplayer-exo:0.6.0"
}
使用方法
java
import org.salient.artplayer.VideoView;
VideoView videoView = new VideoView(this);
videoView.setUp("http://vfx.mtime.cn/Video/2018/06/27/mp4/180627094726195356.mp4");
videoView.setControlPanel(new ControlPanel(this));
videoView.start();
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
public void onBackPressed() {
if (MediaPlayerManager.instance().backPress(this)) {
return;
}
super.onBackPressed();
}
@Override
protected void onPause() {
super.onPause();
MediaPlayerManager.instance().pause();
}
@Override
protected void onDestroy() {
super.onDestroy();
MediaPlayerManager.instance().releasePlayerAndView(this);
}
計劃中
- 音頻播放
- Kotlin版本
不在計劃
- 多播放器播放
支持
- 請在 github 上公開討論技術問題
構建環境
- Java 1.7
- Android Studio 3.1.2
- Gradle 4.4
- IjkPlayer 0.8.8
- ExoPlayer 2.8.3