React-native-track-player: Instance Key Definition [Android]

Created on 13 Feb 2019  路  4Comments  路  Source: react-native-kit/react-native-track-player

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.

Android Question

All 4 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sagargheewala picture sagargheewala  路  3Comments

mnlbox picture mnlbox  路  4Comments

JakeMotta picture JakeMotta  路  3Comments

simenJohnsen picture simenJohnsen  路  3Comments

moduval picture moduval  路  3Comments