Control spotify?

I'm trying to make an app that should be able to control the music I play with spotify (Pause and play). But have no idea how to do it. Spotify has its own api you could use, but how can I use it via app inventor. So what would such a code look like (How should I build such an app?)

Anyone have an idea?