-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJSIExampleModule.kt
36 lines (29 loc) · 1.01 KB
/
JSIExampleModule.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.audiocontext.jsi
import android.util.Log
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.module.annotations.ReactModule
@ReactModule(name = JSIExampleModule.NAME)
class JSIExampleModule(reactContext: ReactApplicationContext?) :
ReactContextBaseJavaModule(reactContext) {
override fun getName(): String {
return NAME
}
@ReactMethod(isBlockingSynchronousMethod = true)
fun install(): Boolean {
try {
System.loadLibrary("react-native-audio-context")
val jsContext = reactApplicationContext.javaScriptContextHolder
nativeInstall(jsContext!!.get())
return true
} catch (exception: Exception) {
Log.e(NAME, "Failed to install JSI Bindings for react-native-audio-context", exception)
return false
}
}
companion object {
const val NAME: String = "JSIExample"
private external fun nativeInstall(jsiPtr: Long)
}
}