Hi,
I just used the playback-state event and saw there is an inconsistency to the docs at least on iOS.
On iOS i logged what I got for the state param and there was a ready state on iOS passed after loading state. But when I log all the state constants listed in the docs there is no ready state and actually two different constants for idle:
// There is not state constant for `ready` ....
console.log(
'play-state: ',
state,
STATE_BUFFERING, // -> loading
STATE_PLAYING, // -> playing
STATE_STOPPED, // -> idle
STATE_NONE, // -> idle
STATE_PAUSED // -> paused
);
Versions:
"react-native": "0.57.8",
"react-native-track-player": "^1.1.3",
It also seems, that when I call play() on the player on iOS, it doesn't start. It starts to switch from idle to loading to ready but then it doesn't start the player when I do not call play() a second time.
So what I do right now on iOS is to call TrackPlayer.play() in the event handler of playback-state on the undocumented ready state. But this can't be the case as it is inconsistent with the android setup right now.
Expected behaviour:
Player starts playing after ready state automatically when it was caused by the TrackPlayer.play() method.
same focuses
Experiencing the same on iOS about the different states and inconsistencies with .play() not working on the first try 馃憤
I have the same issue with play() not working on the first try. I'm noticing the events are firing in this order:
loading => playing => ready => loading => paused
From the second attempt on, the player works as intended.
This doesn't seem to be an issue on v1.0.2. Downgrading fixed the issue for me, for now
For what it's worth; i've started downloading the mp3 before playing it. This fixed it for now. Also fixed a problem displaying the wrong duration and not able to "seek" the track properly because of that wrong duration.
Facing same issue @mikeymaio loading -> playing -> ready on v1.1.8
@nishanBende - same here, would be good if we could get a state for when it's loading
So is it possible to get the current state of TrackPlayer without using event listener? TrackPlayer.STATE_PLAYING seems to always be set to playing on iOS regardless if track is playing or not. Same with other state constants. I thought they'll return the current state of the player. I intend to use it to maintain play button icon (play/pause) in app UI.
Most helpful comment
I have the same issue with play() not working on the first try. I'm noticing the events are firing in this order:
loading => playing => ready => loading => paused
From the second attempt on, the player works as intended.
This doesn't seem to be an issue on v1.0.2. Downgrading fixed the issue for me, for now