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.libq:scrolltrackview:1.0.5'
}
dependencies {
implementation("com.github.libq:scrolltrackview:1.0.5")
}
<dependency>
<groupId>com.github.libq</groupId>
<artifactId>scrolltrackview</artifactId>
<version>1.0.5</version>
</dependency>
libraryDependencies += "com.github.libq" % "scrolltrackview" % "1.0.5"
:dependencies [[com.github.libq/scrolltrackview "1.0.5"]]
类似抖音 IOS 视频音频截取进度条
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
compile 'com.github.libq:ScrollTrackView:1.0.5'
}
<com.libq.scrolltrackview.ScrollTrackView
android:id="@+id/stv"
android:layout_margin="10dp"
android:paddingLeft="10dp"
android:layout_width="match_parent"
android:layout_height="50dp"
app:foreground_color="@color/colorAccent"
app:background_color="@color/colorPrimary"
app:space_size="5dp"
app:track_item_width="1dp"
app:track_fragment_count="10"
app:loop_run="false"
app:cut_duration="10000"
app:auto_run="false"
/>
//1.每个Track小块的数据,不设置也可以,有默认
//float[] template = {0.9f,0.6f,0.7f,0.5f,0.8f,0.4f,0.5f,0.2f,0.6f,0.8f,0.8f};
//stv.setTrackTemplateData(template);
stv.setDuration(20000); // 音频时间
stv.setCutDuration(10000);//屏幕左边跑到右边持续的时间
stv.setTrackFragmentCount(10);//1 中是一个片段,这个参数表示重复1中片段画10次
stv.setLoopRun(true);//设置是否循环跑进度
stv.setSpaceSize(6);
stv.setTrackItemWidth(6);
stv.setOnProgressRunListener(new ScrollTrackView.OnProgressRunListener() {
@Override
public void onTrackStart(int ms) {
}
@Override
public void onTrackStartTimeChange(int ms) {
tv.setText("从 "+ms*1f/1000f+" 秒开始");
}
@Override
public void onTrackEnd() {
}
});