Skip to content

修复底部弹窗问题 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion harmony/sound/src/main/cpp/SoundTurboModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,21 @@ static jsi::Value __hostFunction_NativeSoundTurboModuleSpecJSI_getDuration(jsi::
}

static jsi::Value __hostFunction_NativeSoundTurboModuleSpecJSI_prepare(jsi::Runtime &rt,
react::TurboModule &turboModule,
const jsi::Value *args, size_t count) {
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "prepare", args, count);
}

static jsi::Value __hostFunction_NativeSoundTurboModuleSpecJSI_addListener(jsi::Runtime &rt,
react::TurboModule &turboModule,
const jsi::Value *args, size_t count) {
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "addListener", args, count);
}

static jsi::Value __hostFunction_NativeSoundTurboModuleSpecJSI_removeListeners(jsi::Runtime &rt,
react::TurboModule &turboModule,
const jsi::Value *args, size_t count) {
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "prepare", args, count);
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "removeListeners", args, count);
}

NativeSoundTurboModuleSpecJSI::NativeSoundTurboModuleSpecJSI(const ArkTSTurboModule::Context ctx,
Expand All @@ -166,4 +178,7 @@ NativeSoundTurboModuleSpecJSI::NativeSoundTurboModuleSpecJSI(const ArkTSTurboMod
methodMap_["setNumberOfLoops"] = MethodMetadata{1, __hostFunction_NativeSoundTurboModuleSpecJSI_setNumberOfLoops};
methodMap_["getDuration"] = MethodMetadata{0, __hostFunction_NativeSoundTurboModuleSpecJSI_getDuration};
methodMap_["prepare"] = MethodMetadata{1, __hostFunction_NativeSoundTurboModuleSpecJSI_prepare};
methodMap_["addListener"] = MethodMetadata{1, __hostFunction_NativeSoundTurboModuleSpecJSI_addListener};
methodMap_["removeListeners"] = MethodMetadata{1, __hostFunction_NativeSoundTurboModuleSpecJSI_removeListeners};
}

8 changes: 8 additions & 0 deletions harmony/sound/src/main/ets/SoundTurboModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,12 @@ export class SoundTurboModule extends TurboModule {
Logger.info(TAG, 'sound setNumberOfLoops : '+ value);
this.controller.setNumberOfLoops(value)
}

addListener(eventName: string) {
Logger.info(TAG, 'addListener : '+ eventName);
}

removeListeners(count: number) {
Logger.info(TAG, 'removeListeners : '+ count);
}
}
2 changes: 1 addition & 1 deletion sound.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var RNSound = TurboModuleRegistry?TurboModuleRegistry.get('RNCSound'): ReactNati
var IsAndroid = RNSound.IsAndroid;
var IsWindows = RNSound.IsWindows;
var resolveAssetSource = require("react-native/Libraries/Image/resolveAssetSource");
var eventEmitter = new ReactNative.NativeEventEmitter();
var eventEmitter = new ReactNative.NativeEventEmitter(RNSound);

var nextKey = 0;

Expand Down
4 changes: 4 additions & 0 deletions src/NativeSound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ export interface Spec extends TurboModule {


isPlaying(): boolean

addListener: (eventName: string) => void

removeListeners: (count: number) => void
}

// 'RNCSound' 为最后导出的TurboModule名称,后续通过识别名称来识别模块。
Expand Down