Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.y6909932:artplayer:1.1.0'
}
dependencies {
implementation("com.github.y6909932:artplayer:1.1.0")
}
<dependency>
<groupId>com.github.y6909932</groupId>
<artifactId>artplayer</artifactId>
<version>1.1.0</version>
</dependency>
libraryDependencies += "com.github.y6909932" % "artplayer" % "1.1.0"
:dependencies [[com.github.y6909932/artplayer "1.1.0"]]
English | 简体中文
这是一个灵活的视频播放器。 MediaPlayer与VideoView完全分开,可以替换为其他播放器内核,如ExoPlayer和ijkPlayer。 可以完全自定义播放器视图,我们称之为控制面板。 此外,可以使用MediaPlayerManager来控制播放行为,例如全屏模式,小屏幕模式以及RecyclerView中的智能匹配模式。
<p align="center"> <img src="https://github.com/maiwenchang/ArtPlayer/raw/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png"/> </p><img src="https://github.com/maiwenchang/ArtPlayer/raw/master/pic/main.png" height="500"/><img src="https://github.com/maiwenchang/ArtPlayer/raw/master/pic/mediaplayer.png" height="500"/><img src="https://github.com/maiwenchang/ArtPlayer/raw/master/pic/api.png" height="500"/><img src="https://github.com/maiwenchang/ArtPlayer/raw/master/pic/list.png" height="500"/><img src="https://github.com/maiwenchang/ArtPlayer/raw/master/pic/recyclerview.png" height="500"/><img src="https://github.com/maiwenchang/ArtPlayer/raw/master/pic/extension.png" height="500"/>
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);
}
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.