diff --git a/entry/src/main/cpp/sample/recorder/Recorder.cpp b/entry/src/main/cpp/sample/recorder/Recorder.cpp index 396fd732a2d40fb4983a11ae31d96e11eb4ee33b..8b1418c2aeb487ea97d92158de6d3c78c839fb89 100644 --- a/entry/src/main/cpp/sample/recorder/Recorder.cpp +++ b/entry/src/main/cpp/sample/recorder/Recorder.cpp @@ -42,9 +42,7 @@ int32_t Recorder::Init(SampleInfo &sampleInfo) { videoEncoder_ = std::make_unique(); muxer_ = std::make_unique(); - int32_t ret = videoEncoder_->Create(sampleInfo_.videoCodecMime); - CHECK_AND_RETURN_RET_LOG(ret == AVCODEC_SAMPLE_ERR_OK, ret, "Create video encoder failed"); - ret = muxer_->Create(sampleInfo_.outputFd); + int32_t ret = muxer_->Create(sampleInfo_.outputFd); CHECK_AND_RETURN_RET_LOG(ret == AVCODEC_SAMPLE_ERR_OK, ret, "Create muxer with fd(%{public}d) failed", sampleInfo_.outputFd); ret = muxer_->Config(sampleInfo_); diff --git a/entry/src/main/cpp/sample/recorder/RecorderNative.cpp b/entry/src/main/cpp/sample/recorder/RecorderNative.cpp index 91894ea9e06f930b84c1f6db57a7afa47a27466b..9feea1606cc79668141a70af9f05ad4f19d31c08 100644 --- a/entry/src/main/cpp/sample/recorder/RecorderNative.cpp +++ b/entry/src/main/cpp/sample/recorder/RecorderNative.cpp @@ -146,14 +146,8 @@ napi_value RecorderNative::Stop(napi_env env, napi_callback_info info) { asyncCallbackInfo->asyncWork = nullptr; asyncCallbackInfo->deferred = deferred; - napi_value resourceName; - napi_create_string_latin1(env, "recorder", NAPI_AUTO_LENGTH, &resourceName); - napi_create_async_work( - env, nullptr, resourceName, [](napi_env env, void *data) { NativeStop(env, data); }, - [](napi_env env, napi_status status, void *data) { DealCallBack(env, data); }, (void *)asyncCallbackInfo, - &asyncCallbackInfo->asyncWork); - napi_queue_async_work(env, asyncCallbackInfo->asyncWork); - return promise; + NativeStop(env, asyncCallbackInfo); + return nullptr; } EXTERN_C_START diff --git a/entry/src/main/ets/pages/Recorder.ets b/entry/src/main/ets/pages/Recorder.ets index 2d1264082b10a4793cc47cfe7f2500b1f75bb0ae..b6da2d237e172485dc65f0d337f0c367a526b77b 100644 --- a/entry/src/main/ets/pages/Recorder.ets +++ b/entry/src/main/ets/pages/Recorder.ets @@ -155,12 +155,9 @@ struct Recorder { this.seconds = 0; this.videoRecorderTimeText = Const.DEFAULT_TIME; - recorder.stopNative().then(async (data) => { - if (data.code === 0) { - await releaseCamera(); - this.playFlag = false; - } - }); + recorder.stopNative(); + await releaseCamera(); + this.playFlag = false; } }