Gesture Based Music Player


Controlling an application using gestures needs a software so that it be able to receive gestures from human and perform appropriate tasks. Based on our goal we decided to control a music player by a glove through doing some gestures. I decided to control Spotify client, but because it doesn’t provide appropriate api to control client, I had to develop my own music player such that it can receive commands from glove and perform some tasks like play and pause a music. We used “pyspotify” and “spotipy” libraries to develop a simple music player in python by connecting to Spotify server. This application lets us to search for a music in spotify database and do “play”, “pause”, “stop”, “fast forward” 10 and 20 seconds  and “rewind” 10 and 20 seconds.



First thing you need for developing your own Spotify client is a Premium account. Then you have to download your application key from spotify and put it into the same directory as your py files.

We developed this app with Python and by using these libraries:

  • pyQt: This is a library for developing cross-platform GUIs. You can read more about this library at:
  • pyspotify: This library is a wrapper around spotify api and lets us to play a music from Spotify server and control it. But, there is a problem with this library. Because Spotify has deprecated “libspotify” and it is used in pyspotify you can’t use this library for searching in the Spotify database. you can find more information about this library at
  • spotipy: We used this library as a complement to pyspotify. That is to say for searching a music we use this library. You can read more about spotipy at:

Figure 1

Figure 1 demonstrates our spotify client UI. In the search box you can search for a music by typing the name of artist or title of music and then the list of all related tracks will be shown in the middle list box. Then we can control the music by typing commands in the command bar.

The available commands are:

  • “play”: to play a music
  • “pause”: to pause a music
  • “stop”: to stop a music
  • “ff”: to fast forward a music for 10 seconds
  • “ff2”: to fast forward a music for 20 seconds
  • “r”: to rewind a music for 10 seconds
  • “r2”: to rewind a music for 20 seconds

The code for this app is provided in my github. You can check it for seeing all the details. But here I just want to describe the functions that I have in my code very briefly:

main: We create a QtGui application in main by initiating an object from SpotifyGUI class


  • init: In this method we create a connection to Spotify server (you have to fill username and password by yours first) and initiate UI window
  • initUI: In this method we create the text boxes and the list widget to show the list of tracks. We also connect the event handler of these widgets to appropraite methods.
  • searchMusic: this is the event handler for search bar. It uses spotipy library to search the string that user has entered in spotify database and shows the list of related music in the list widget and then it uses pyspotify library to play the first track returned from spotify server.
  • itemClickedFunction: this is the event handler for list widget and plays the item which is selected by user by using pyspotify library.
  • runCommand: this is the event handler for command bar. based on the command that user has entered this method performs appropriate task (play, pause, … ) by using pyspotify library.

For seeing more details please check the code on github.

We added more functions to this music player in third week to control it with gestures.


This entry was posted in Project 2.2. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s