Skip to content

Commit

Permalink
feat(android): add maxAccurateDelta api
Browse files Browse the repository at this point in the history
  • Loading branch information
I-m-SuperMan authored and pingkai committed Mar 19, 2020
1 parent cde71a4 commit 31ba7ec
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,18 @@ public int getValue() {
*/
abstract public void seekTo(long position, SeekMode seekMode);

/**
* 设置精准seek的最大间隔。
* @param delta 间隔时间,单位毫秒
*/

/****
* set the maximum interval of precision seek.
* @param delta interval in milliseconds
*/

abstract public void setMaxAccurateSeekDelta(int delta);

/**
* 重置。
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,11 @@ public void seekTo(long positionMs, SeekMode mode) {
mCorePlayer.seekTo(positionMs, mode.getValue());
}

@Override
public void setMaxAccurateSeekDelta(int delta){
mCorePlayer.setMaxAccurateSeekDelta(delta);
}


// @Override
// public int getPlayerStatus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void loge(String tag, String msg) {
System.loadLibrary("CicadaPlayer");
}


private static class MainHandler extends Handler {
private WeakReference<NativePlayerBase> playerWeakReference;

Expand Down Expand Up @@ -194,6 +195,11 @@ public void seekTo(long position, int mode) {
nSeekTo(position, mode);
}


public void setMaxAccurateSeekDelta(int delta) {
nSetMaxAccurateSeekDelta(delta);
}

public long getDuration() {
long duration = nGetDuration();

Expand Down Expand Up @@ -469,6 +475,8 @@ public static void setBlackType(int type) {

protected native void nSeekTo(long position, int mode);

protected native void nSetMaxAccurateSeekDelta(int delta);

protected native void nStop();

protected native void nRelease();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ void NativeBase::java_SeekTo(JNIEnv *env, jobject instance, jlong position, jint
player->SeekTo(position, (SeekMode) mode);
}

void NativeBase::java_SetMaxAccurateSeekDelta(JNIEnv *env, jobject instance, jint delta)
{
AF_TRACE;
MediaPlayer *player = getPlayer(env, instance);

if (player == nullptr) {
return;
}

player->SetOption("maxAccurateSeekDelta", AfString::to_string((int)delta).c_str());
}


void NativeBase::java_Stop(JNIEnv *env, jobject instance)
{
Expand Down Expand Up @@ -908,6 +920,7 @@ static JNINativeMethod nativePlayer_method_table[] = {
{"nSetVolume", "(F)V", (void *) NativeBase::java_SetVolume},
{"nGetVolume", "()F", (void *) NativeBase::java_GetVolume},
{"nSeekTo", "(JI)V", (void *) NativeBase::java_SeekTo},
{"nSetMaxAccurateSeekDelta", "(I)V", (void *) NativeBase::java_SetMaxAccurateSeekDelta},
{"nStop", "()V", (void *) NativeBase::java_Stop},
{"nRelease", "()V", (void *) NativeBase::java_Release},
{"nGetDuration", "()J", (void *) NativeBase::java_GetDuration},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class NativeBase {

static void java_SeekTo(JNIEnv *env, jobject instance, jlong position, jint mode);

static void java_SetMaxAccurateSeekDelta(JNIEnv *env, jobject instance, jint delta);

static void java_Stop(JNIEnv *env, jobject instance);

static void java_Release(JNIEnv *env, jobject instance);
Expand Down

0 comments on commit 31ba7ec

Please sign in to comment.