Skip to content
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

Fix onEvent never triggered on PlayerView on Android #327

Merged
merged 1 commit into from
Nov 24, 2023

Conversation

rolandkakonyi
Copy link
Contributor

@rolandkakonyi rolandkakonyi commented Nov 23, 2023

Description

Found that <PlayerView onEvent={}> callback was never triggered on Android.
This would simplify implementing use cases when looking at all events, like for a player testing framework's event expectation system.

Changes

Turned out that this is not supported out of the box on Android.
I have implemented it on the React Native side, within RNPlayerView.
Events coming from the player are now emitted through onEvent as well.
I didn't include view events as we don't support that on any of the native platforms.

For manual testing, add this to any <PlayerView />:

onEvent={(event) => console.log(`onEvent [${event.name}]`)}

Checklist

  • 🗒 CHANGELOG entry

@rolandkakonyi rolandkakonyi self-assigned this Nov 23, 2023
@@ -25,7 +25,6 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
import kotlin.reflect.KClass

private val EVENT_CLASS_TO_REACT_NATIVE_NAME_MAPPING = mapOf(
PlayerEvent::class to "event",
Copy link
Contributor Author

@rolandkakonyi rolandkakonyi Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did nothing, so I removed it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a flaw in our event emitter. From a typing perspective one would expect that this works - but it doesn't.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification! It confused me too!

@rolandkakonyi rolandkakonyi marked this pull request as ready for review November 23, 2023 14:40
Copy link
Contributor

@strangesource strangesource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch and clean solution. 💪

@@ -25,7 +25,6 @@ import com.facebook.react.uimanager.events.RCTEventEmitter
import kotlin.reflect.KClass

private val EVENT_CLASS_TO_REACT_NATIVE_NAME_MAPPING = mapOf(
PlayerEvent::class to "event",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a flaw in our event emitter. From a typing perspective one would expect that this works - but it doesn't.

@rolandkakonyi rolandkakonyi merged commit 9b447c9 into development Nov 24, 2023
9 checks passed
@rolandkakonyi rolandkakonyi deleted the fix-onEvent-support-on-android branch November 24, 2023 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants