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.lichmeng:myijkplayer:v1.3'
}
dependencies {
implementation("com.github.lichmeng:myijkplayer:v1.3")
}
<dependency>
<groupId>com.github.lichmeng</groupId>
<artifactId>myijkplayer</artifactId>
<version>v1.3</version>
</dependency>
libraryDependencies += "com.github.lichmeng" % "myijkplayer" % "v1.3"
:dependencies [[com.github.lichmeng/myijkplayer "v1.3"]]
自己编译的安卓源码,修改直播缓冲,去掉-example中无用的activity,fragment,及资源文件,精简arm平台库并将其以jnilibs文件夹的形式将.so文件添加到-example中;方便将其集成到其他的工程中. 将该库以module或library的形式导入,或打包成jar或aar的形式进行集成. 参考记录<项目中集成ijkplayer官方demo>
public class TestActivity extends AppCompatActivity {
private AndroidMediaController mMediaController;
private IjkVideoView mVideoView;
String mVideoPath = "rtmp://live.hkstv.hk.lxdns.com/live/hks";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
mMediaController = new AndroidMediaController(this, false);
// init player
IjkMediaPlayer.loadLibrariesOnce(null);
IjkMediaPlayer.native_profileBegin("libijkplayer.so");
mVideoView = (IjkVideoView) findViewById(R.id.video_view_test);
mVideoView.setMediaController(mMediaController);
mVideoView.setVideoPath(mVideoPath);
mVideoView.start();
}
}
<tv.danmaku.ijk.media.example.widget.media.IjkVideoView
android:id="@+id/video_view_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>