I am getting a warning saying "registerHeadless Task called multiple times for same key 'TrackPlayer'". I am using two instances, how do I setup key for each instance of track player that I create ?
The event registration is not working for one of the instances.
What do you mean by "creating two instances"? Can you elaborate?
You should use registerPlaybackService or registerEventHandler just after running AppRegistry.registerComponent. Don't use those functions anywhere else.
@Guichaguri Yes, I call registerEventHandler twice, thats why I am saying "creating two instances". One is to play normal songs and the other is to play ads. When I play ads and normal songs with the same "instance", it gets very bug and things on playback-queue-ended don't go well. I tried to use a flag to signalize when its ad but its not working very well.
So I register events for normal songs and ads, using registerEventHandler but I am getting the notification "registerHeadless Task called multiple times for same key 'TrackPlayer" and the events for the instance that control normal songs are not firing.
react-native-track-player is designed to only work with one instance at once. My suggestion is to add a flag isPlayingAds and check it before processing any event.
Thank you! @Guichaguri I am asking because its working perfectly on IOS, I will use the flag.