Run react-native info in your project and share the content.
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 116.47 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.15.1 - ~/.nvm/versions/node/v8.15.1/bin/node
npm: 6.4.1 - ~/.nvm/versions/node/v8.15.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 26, 27, 28
Build Tools: 28.0.2, 28.0.3
System Images: android-28 | Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.4
npmGlobalPackages:
react-native-cli: 2.0.1
What react-native-track-player version are you using?
The state constants in the documentation do not match the state constants the track player uses.
Rather than the ones listed here https://react-native-kit.github.io/react-native-track-player/documentation/#constants, the track player state constants are a series of numbers on android, and strings such as 'playing', 'paused', 'loading' etc on iOS.
Also, I haven't been able to figure out which of these constants relates to 'STATE_STOPPED'.
The documented state constants look a lot nicer to develop with.
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (4) x64 Intel(R) Core(TM) i5-2415M CPU @ 2.30GHz
Memory: 32.14 MB / 10.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.14.0 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: ^0.59.6 => 0.59.6
npmGlobalPackages:
react-native-cli: 2.0.1
track player
[email protected]
by the way, console.log(TrackPlayer.STATE_STOPPED); prints 1 in android
for checking the player state, i use the following code
if (TrackPlayer.getState() == TrackPlayer.STATE_PLAYING) which suffices my need
Yes, the constants in the docs are indeed exposed in JS as constants.
You should compare the state with one of the constants, as @bishnudev described.