React-native-track-player: TrackPlayer.STATE_NONE (undefined is not an object)

Created on 26 Dec 2017  路  11Comments  路  Source: react-native-kit/react-native-track-player

Hi guys,

looks like i have that problem like previously @chrissbendel had in issue #96.
I have tried that guide that he provided, but no success. I`m able to reproduce it only for iOS.

My configuration:
"react": "16.0.0",
"react-native": "^0.50.3",
"react-native-track-player": "^0.2.2"
I`m running my sample on iOS. Simulator v11.2

Can you please help how i can fix it?

Thanks in advance.

Most helpful comment

Hello @dcvz - Good day! just an inquiry...have you published a new npm?

All 11 comments

Since #96 was closed, I comment here as well:

I'm having a similar issue. I have dummy.swift and also 'react-native link' linked the library fine. However, if I do react-native run-ios, build fails with the following message:

=== BUILD TARGET RNTrackPlayer OF PROJECT RNTrackPlayer WITH CONFIGURATION Debug ===

Check dependencies

Swift is not supported for static libraries.

** BUILD FAILED **

I can run it on Android successfully and can play both mp3, HLS & IceCast 2.4, though!

"react": "16.0.0",
"react-native": "0.50.3",
"react-native-track-player": "^0.2.2",

is what I have.

I had XCode 8 and that was the issue. I updated it to 9.2 and now I can compile it and run on the iPhone simulator. At the moment I can play a local MP3 file, HLS and IceCast 2.4 on the simulator.

I would LOVE to be able to play local files in the iPhone Simulator. I have XCode 9.2 but I can't get past the TrackPlayer.STATE_NONE issue.

I have something like this and it works:

The main file:

AppRegistry.registerComponent('MyProject', () => AppStack);
TrackPlayer.registerEventHandler(require('./playerHandler.js'));

./playerHandler.js I have is for now empty (I just copied from the guide):

module.exports = async (data) => {
    if(data.type == 'playback-state') {
        // Update the UI with the new state
    } else if(data.type == 'remote-play') {
        // The play button was pressed, we can forward this command to the player using
        //TrackPlayer.play();
    } else if(data.type == 'remote-seek') {
        // Again, we can forward this command to the player using
        //TrackPlayer.seekTo(data.position);
    }
    // ...
};

And then in the main component, I have this code from the guide:

componentDidMount() {    
    // Creates the player
    TrackPlayer.setupPlayer().then(async () => {
        // Adds a track to the queue
        await TrackPlayer.add({
            id: 'trackId',
            // url: 'STREAM_OR_FILE_URL',
            url: require('LOCAL_FILE_LOCATION'),
            title: 'Track Title',
            artist: 'Track Artist',
            // artwork: require('track.png')
        });
        // Starts playing it
        TrackPlayer.play();
    });
  }

@michaelfranz Does it work for you on Android?

Guys, i have installed xCode 9.2 and i`m not interested in Android. My question was about iOS version of the library.

@SatoshiInoue are you asking to check is it working on Android?

I had this issue as well - turns out my link didn't run correctly.

Try running react-native link react-native-track-player again or follow the manual linking step.

Zarbuto's suggestion worked for me on iOS. I haven't tried Android yet.

@Ciget - I was trying to narrow down possible causes by knowing whether it works on Android so that you'd know if it's an OS specific issue or the build/react setup issue. For sure you should care about building with Android, given React Native is a cross-platform solution:) Otherwise, you'd be better off doing straight iOS development.

This has been fixed with: ade467305003890273a271881051ca2535bd39ec and 5e2ce7db043a16fe26af6f3237b7488c57541024

Until we publish a new npm version, please feel free to use the repo directly.

Hello @dcvz - Good day! just an inquiry...have you published a new npm?

Can I use the library in Snack

Was this page helpful?
0 / 5 - 0 ratings