-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
@@ -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", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this 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", |
There was a problem hiding this comment.
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.
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 />
:Checklist
CHANGELOG
entry