完成动画序列播放
This commit is contained in:
@@ -196,7 +196,7 @@ void CppCallback()
|
||||
}
|
||||
|
||||
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnLoadActionFinished", "(Ljava/lang/String;)V");
|
||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnLoadMotionListFinished", "(Ljava/lang/String;)V");
|
||||
if (methodId == nullptr) {
|
||||
env->ExceptionDescribe(); // 打印异常
|
||||
env->ExceptionClear();
|
||||
@@ -258,7 +258,7 @@ void CppAnimationFinishedCallback()
|
||||
}
|
||||
|
||||
// 2. 获取 OnLoadActionFinished 方法 ID(注意方法名大小写必须一致!)
|
||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnAnimationFinished", "()V");
|
||||
jmethodID methodId = env->GetMethodID(callbackClass, "OnPlayMotionListFinished", "()V");
|
||||
if (methodId == nullptr) {
|
||||
env->ExceptionDescribe(); // 打印异常
|
||||
env->ExceptionClear();
|
||||
@@ -313,6 +313,25 @@ Java_com_hmwl_face_1sdk_FaceActivity_PreReadAction(JNIEnv *env, jobject thiz, js
|
||||
return env->NewStringUTF(ret.c_str());
|
||||
}
|
||||
|
||||
const char DELIMITER = 0x1F; // same as \u001F
|
||||
|
||||
std::vector<std::string> splitMotionString(const std::string& input) {
|
||||
std::vector<std::string> result;
|
||||
if (input.empty()) return result;
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = input.find(DELIMITER);
|
||||
|
||||
while (pos != std::string::npos) {
|
||||
result.push_back(input.substr(start, pos - start));
|
||||
start = pos + 1;
|
||||
pos = input.find(DELIMITER, start);
|
||||
}
|
||||
// Add last part
|
||||
result.push_back(input.substr(start));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
@@ -336,6 +355,18 @@ Java_com_hmwl_face_1sdk_FaceActivity_ChangeMotionCpp(JNIEnv *env, jobject thiz,
|
||||
|
||||
if(g_Application->isInited())
|
||||
{
|
||||
g_Application->changeMotionList(CppAnimationFinishedCallback, loop);
|
||||
std::vector<std::string> motions = splitMotionString(nativeString);
|
||||
g_Application->changeMotionList(motions, CppAnimationFinishedCallback, loop);
|
||||
}
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_StopMotionNative(JNIEnv *env, jobject thiz) {
|
||||
g_Application->StopMotion();
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_hmwl_face_1sdk_FaceActivity_ResumeMotionNative(JNIEnv *env, jobject thiz) {
|
||||
// TODO: implement ResumeMotionNative()
|
||||
g_Application->ResumeMotion();
|
||||
}
|
||||
Reference in New Issue
Block a user