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

[BUG] Playlist change event object emitted as string instead of PlaylistItem type #92

Open
cheynewallace opened this issue Oct 15, 2024 · 0 comments
Labels
bug Something isn't working Groomed JWP team has reviewed the ticket and deemed it necessary

Comments

@cheynewallace
Copy link

Describe the bug
When handling playlist item change events the event.nativeEvent.playlistItem should be of PlaylistItem interface, but instead it is coming through as a string which means you cannot access it's properties such as title, description etc without JSON parsing.

To Reproduce

const handleOnPlaylistItemChange = (event: BaseEvent<PlaylistItemEventProps>) => {
	console.log("Playlist Item Type", typeof event.nativeEvent?.playlistItem);
};

<JWPlayer ref={playerRef} onPlaylistItem={handleOnPlaylistItemChange}/>

In the above example, I get the output: Playlist Item Type string

Expected behavior
It should be an object of type PlaylistItem according to: https://github.com/jwplayer/jwplayer-react-native/blob/master/index.d.ts#L500

Device(s) affected
All devices

Additional context
As a hacky workaround work around

let eventPlaylistItem = null;
if (typeof event.nativeEvent?.playlistItem === "string") {
	eventPlaylistItem = JSON.parse(event.nativeEvent?.playlistItem);
} else {
	eventPlaylistItem = event.nativeEvent?.playlistItem;
}
@cheynewallace cheynewallace added the needs-grooming Has not been reviewed by codeowners for scope/validation label Oct 15, 2024
@Jmilham21 Jmilham21 added bug Something isn't working Groomed JWP team has reviewed the ticket and deemed it necessary and removed needs-grooming Has not been reviewed by codeowners for scope/validation labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Groomed JWP team has reviewed the ticket and deemed it necessary
Projects
None yet
Development

No branches or pull requests

2 participants