Skip to content

fix: fixed typo #531

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions apps/common-app/src/examples/AudioFile/AudioFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ const AudioFile: FC = () => {

const interruptionSubscription = AudioManager.addSystemEventListener(
'interruption',
(event) => {
console.log('Interruption event:', event);
async (event) => {
if (event.type === 'began') {
await AudioPlayer.pause();
setIsPlaying(false);
}
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ void AudioAPIModule::invokeHandlerWithEventNameAndEventBody(
} else if (value->isInstanceOf(jni::JFloat::javaClassStatic())) {
body[name] = jni::static_ref_cast<jni::JFloat>(value)->value();
} else if (value->isInstanceOf(jni::JBoolean::javaClassStatic())) {
body[name] = jni::static_ref_cast<jni::JBoolean>(value)->value();
auto booleanValue = jni::static_ref_cast<jni::JBoolean>(value)->value();

if (booleanValue) {
body[name] = true;
} else {
body[name] = false;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AudioFocusListener(
private val audioAPIModule: WeakReference<AudioAPIModule>,
private val lockScreenManager: WeakReference<LockScreenManager>,
) : AudioManager.OnAudioFocusChangeListener {
private var playOnAudioFocus = false
private var playOnAudioFocus: Boolean = false
private var focusRequest: AudioFocusRequest? = null

override fun onAudioFocusChange(focusChange: Int) {
Expand All @@ -23,7 +23,7 @@ class AudioFocusListener(
playOnAudioFocus = false
val body =
HashMap<String, Any>().apply {
put("value", "began")
put("type", "began")
put("shouldResume", false)
}
audioAPIModule.get()?.invokeHandlerWithEventNameAndEventBody("interruption", body)
Expand All @@ -32,7 +32,7 @@ class AudioFocusListener(
playOnAudioFocus = lockScreenManager.get()?.isPlaying == true
val body =
HashMap<String, Any>().apply {
put("value", "began")
put("type", "began")
put("shouldResume", playOnAudioFocus)
}
audioAPIModule.get()?.invokeHandlerWithEventNameAndEventBody("interruption", body)
Expand All @@ -41,14 +41,14 @@ class AudioFocusListener(
if (playOnAudioFocus) {
val body =
HashMap<String, Any>().apply {
put("value", "ended")
put("type", "ended")
put("shouldResume", true)
}
audioAPIModule.get()?.invokeHandlerWithEventNameAndEventBody("interruption", body)
} else {
val body =
HashMap<String, Any>().apply {
put("value", "ended")
put("type", "ended")
put("shouldResume", false)
}
audioAPIModule.get()?.invokeHandlerWithEventNameAndEventBody("interruption", body)
Expand Down