SpotifyBox - These - Antoine GUITTET - 2016

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 39

SPOTIFY BOX

ANTOINE GUITTET

September 2016
AG612 – 7217 words
Supervised by MICHAEL KAMPOURIDIS

A dissertation submitted for the Master’s Degree of Computing and


Entrepreneurship

Spotify Box University of Kent

Acknowledgments

Firstly, I would like to express my gratitude to my dissertation supervisor, professor


Michael Kampouridis, for his help, trust, patience and support on this project. I
would also like to thank the Shed, for spending their time by sharing their knowledge
with the students and help us to succeed in our projects.

2
Spotify Box University of Kent

Abstract

The emergence of music streaming service allowed access of a new consumption of


music and a perception of an unlimited catalogue. However, some categories of person
may feel a break on the adoption of this new service. Firstly, we have the music
amateurs who potentially would want to maintain the physical support and keep
collecting cd covers. The second category of people, those are sensitive to the music
dematerialisation, is constituted of people with an insufficient knowledge in
computing. Those people are uncomfortable with the new technologies and are not
able to use entirely the power of these new services offered by music streaming
companies. This master’s degree project aims to determine a new approach of music
consumption based on music streaming services in order to keep the benefits, but also
its accessibility for everyone. This approach will bring back the physical support by
designing and developing a new type of NFC Spotify player. This player will be able
to scan a cd cover containing an NFC tag with a Spotify Uri written in it and able to
play it. The physical library will be managed via a smartphone application able to write
and consult tags. All the design and development process will be oriented around the
user’s accessibility. In the future, this box will also aim to be a new support for the
research and determine the different user’s behaviours between classical software
platform and physical platform. The Spotify box project will be fast prototyped with
the new process of 3D printing and using accessible electronic components such as
Raspberry Pi which could be easily and rapidly reproducible for research. This paper
demonstrates the reflection behind the final product, and presents the complete process
and choices which has been made.

3
Spotify Box University of Kent

List of figures

Figure 1. Use case diagram for mobile application ................................................... 17


Figure 2 Use case diagram for Spotify Box ................................................................ 17
Figure 3 Spotify Box during the prototyping phase ................................................... 25
Figure 4 3D model of the Spotify Box ........................................................................ 30

4
Spotify Box University of Kent

Table of Contents
Acknowledgments .......................................................................................................... 2
Abstract .......................................................................................................................... 3
1. Introduction ................................................................................................... 7
1.1 Background, context and motivation ............................................................... 7
1.2 Aims of the motivation .................................................................................... 8
1.3 Demonstration of the final results .................................................................... 9
2. Literature review ......................................................................................... 10
2.1 Overview ....................................................................................................... 10
2.2 Research around Spotify ................................................................................ 10
2.2.1 Using NFC with Spotify (Lochrie, Burnett, & Coulton, 2013) ........................... 11
2.2.2 User behaviour in Spotify (Zhang, 2013) ......................................................... 12
2.2.3 Other relevant projects ................................................................................... 13
3. Conception .................................................................................................. 14
3.1 Overview ....................................................................................................... 14
3.2 Objectives ...................................................................................................... 14
3.3 Functional requirements ................................................................................ 15
3.4 Non-functional requirements ......................................................................... 15
3.5 Functional constrains ..................................................................................... 16
3.6 Project architecture ....................................................................................... 17
3.6.1 Use-case diagram ............................................................................................ 17
3.6.2 Sequence diagrams .......................................................................................... 18
3.7 Methodology ................................................................................................. 18
3.7.1 Overview .......................................................................................................... 18
3.7.2 Agile method ................................................................................................... 18
3.7.3 Sources management ...................................................................................... 19
3.7.4 Testing ............................................................................................................. 20
3.8 Conclusion ..................................................................................................... 20
4. Implementation ........................................................................................... 21
4.1 Overview ....................................................................................................... 21
4.2 Box ................................................................................................................ 21
4.2.1 Presentation .................................................................................................... 21
4.2.2 Technology ...................................................................................................... 21
4.2.3 Architecture ..................................................................................................... 22
4.2.4 Implementation ............................................................................................... 23
4.2.5 Conclusion ....................................................................................................... 25
4.3 Application .................................................................................................... 26
4.3.1 Presentation .................................................................................................... 26
4.3.2 Technology ...................................................................................................... 26
4.3.3 Architecture ..................................................................................................... 27
4.3.4 Implementation ............................................................................................... 28
4.3.5 Conclusion ....................................................................................................... 28
4.4 3D printing ..................................................................................................... 28
4.4.1 Presentation .................................................................................................... 28
4.4.2 Technology ...................................................................................................... 29
4.4.3 Software .......................................................................................................... 29
4.4.4 Modelling ......................................................................................................... 29
4.4.5 Conclusion ....................................................................................................... 30

5
Spotify Box University of Kent

5. Tests ............................................................................................................ 31
5.1 Overview ....................................................................................................... 31
5.2 Use-case tests ................................................................................................ 31
5.3 Software tests ................................................................................................ 31
5.4 Conclusion ..................................................................................................... 32
6. Summary ..................................................................................................... 32
6.1 Completion of objectives ............................................................................... 32
6.2 Future directions ............................................................................................ 33
6.2.1 Box ................................................................................................................... 33
6.2.2 Application ....................................................................................................... 33
6.2.3 3D printing ....................................................................................................... 34
6.2.4 Data mining ..................................................................................................... 34
6.3 Final conclusion ............................................................................................. 34
7. Appendices .................................................................................................. 36
7.1 Sequence diagram of music playing process ................................................... 36
7.2 Sequence diagram of tag managing ................................................................ 37
Bibliography ........................................................................................................ 38

6
Spotify Box University of Kent

1. Introduction

1.1 Background, context and motivation

Media streaming services are becoming one of biggest internet usage,
supported by the emergence of the cloud computing and the increasing
power of servers and network systems. The media streaming, which includes
every type of media from music to movies via video-games, is becoming a
common use for a large panel of people. Watching a movie or playing a song
from these platforms becomes a part of everyday life and an answer to a
strong customer's request. The 2015 Global media report of McKinsey
Company shows that the digital consumer spending (including all types of
streaming services) rose to 5.5 percent between 2014 and 2015 (McKinsey &
Company, 2015). Their estimation shows that the digital consumption will
surpass the traditional one around the year 2017.

Music streaming is one the of major streaming practices, with Spotify as a
leader in this domain. Spotify holds a hundred million of active user in the
first quarter of 2016 (Statista, 2016). In these hundred million, thirty million
of them are paying an account (statista, 2016). In consequence, Spotify out
distance its competitor Apple Music and Deezer.

The attraction of users for the dematerialised music is based on two main
assets: the feeling of unlimited resources (with more than 20 million tracks
available) and a pricing solution where the classical CD consumption cannot
compete. The common price for music streaming services are around ten
pounds per month to access the full Spotify catalogue, while the cost of one
CD turns around the same price.

7
Spotify Box University of Kent

However, the complete dematerialisation has its limits, and music streaming
services find themselves face to face with a part of the population not-
sensible or inaccessible for their solution.
This category of non-sensitive people, perceive the music streaming as a
noxious service to the music industry. It induces the closure of cd retailers,
the loss of physical support and thereby the loss of the cd cover library and
trade between music fans.
The second category could be called the inaccessible market. Their
inaccessibility can be due to several reasons: an insufficient background in
computing to be able to use and manage the Spotify client, or an unsuitable
equipment.

In view of this observation and using my entourage to confirm this need, I
tried to investigate a new way to consume the music stored in the cloud,
but also for it to become accessible for the largest amount of people.

1.2 Aims of the motivation



Following my initial research to elaborate my first statement of this
niche market for Spotify, but more generally for all the streaming music
provider; I discovered an unknown word and beyond it a new concept [4]. This
word was “Phygital”. Complex to define, it is the contraction between the
“physical” and the “digital”, which describes the movement that creates a
transparent ecosystem between the user environment and the power of the
digital. Properly used in the marketing and business context, it is today
applied also for the Internet of Things domain.

I decided to design and develop a physical device, able to facilitate the
interaction between the user and Spotify while keeping the cd covers.

8
Spotify Box University of Kent

The goal of this dissertation is to create a connected box, accompanied


with its application. This box will be able to play a given Spotify Uri through
the different Spotify tools, API and SDK. To communicate the track Uri to the
box, we will use the NFC technology. The Uri will be stored in an NFC tag,
hidden in a cd cover. When we will pass the cd cover onto the box, the tag
will be read and the Uri played. The application will be used as a tool to
manage the use tag library by reading and writings the tags. To prototype the
product in the short period of time of the dissertation, we will use the fast
prototyping methods and in particular the 3D printing technology by creating
a 3D model of the box design, and print it thanks to the Shed equipment. One
of the interesting aspects of this project will be the reusability of the Spotify
Box for future researches. In effect, this product is originally designed for end-
user but can also be used as an instrument to generate a new kind of data,
data of user behaviour with streaming service from a physical platform.

1.3 Demonstration of the final results



In order to demonstrate the functionalities and features of the Spotify
box, a presentation video has been realised, and available at this address
http://bit.ly/2bVPDMp. This shortened URL link targets the Dropbox
repository where the video which presents the box design, is stored.

In this first chapter the box will be presented from the inside, as well
as the outside, and the 3D printing process. Once the first presentation done,
the demonstration starts by browsing Spotify via the Spotify Box application
and write the chosen track on a tag. Then, we will consult the content of the
written tag to certify that the music has been correctly written. Finally, we
will try to add a Spotify URI manually in the supposed section in the app.

Once the tags are ready, we will start the demonstration of the
features of the box by plugging the cables and start the box. The first tag to

9
Spotify Box University of Kent

play will be the tag containing the single track. We will play the music, then
present how to play an album and change the music to the next track. Finally,
we will validate the error messages by the led system when a tag is not
readable.

2. Literature review

2.1 Overview

The multidisciplinary of the Spotify box turns out to be the one of the
major obstacles to success in the development of this project. Being based at
the same time on a mobile application, an embedded software and a 3D
printed box with electronic in it, this proposal requires a large background in
several technologies. The literature review has for purpose to determine
meticulously the technologies that has already been used in similar projects,
compare their process with mine, and consider how to improve them for my
own by using their success, errors or failures.

2.2 Research around Spotify



Spotify and music streaming services have been the subject of plenty of
researches since their creation. These researches are focused on one hand
with the peering technology that Spotify developed to reduce its response
time, and on the other hand about the algorithm of playlist generation.
However, only few researches are working on the development of new
interfaces between Spotify and its users. Among them one was attractive and
interesting to link with my own research.


10
Spotify Box University of Kent

2.2.1 Using NFC with Spotify (Lochrie, Burnett, & Coulton, 2013)

Named “Using NFC check-ins to crowd curate music preferences” is a work
led by Mark Lochrie, Daniel Burnett and Paul Coulton. The purpose of this
research is to integrate a check-in system into a new shape of Jukebox called
CheckinDJ. Existing as a duo of connected box and its web platform, this
connected Jukebox will be presented in bars.

The bar’s clients will fill their users’ profiles on the web platform with their
personal information, yet they also have the possibility to link their Twitter,
Facebook or Foursquare account to get more impact during the music choice.
This user profile is assigned to a NFC tag, given previously by the bar’s owner
to the client (which can be embedded in cups or bar coasters). Just after the
client has scanned his NFC tag onto the jukebox, he will be asked to set his
three favourites music genres. The music genre which has been selected the
most will be played. Each client increases the music genre mark by 1 when he
puts it in his genre selection, but can increase his influence to a higher mark
if he promotes the bar on his social networks, check-in the presence in the
bar or else share the current playlist.

This paper has proved that the viability of a check-in system is real. If the
solution is correctly encapsulated into a solution designated for the final client
like a new and useful service, it could be used in various events and venues.
However, despite the correct integration of the check-in system in a music
player, the survey has shown the lack of the playlist algorithm. The system
takes the music genre with the highest rank then selects a group of 50 artists
within that genre. One single artist is picked from that genre and a random
track of this artist is chosen. This research selection method induces that it
would play totally unknown songs that could not be in the music genre
selected. In spite of a few positive comments, the common opinion found the
selected music quite a niche.

11
Spotify Box University of Kent

Beyond the music aspect, a technical presentation would have been


appreciated, such as the choice of NFC to the detriment of RFID tags, less
expensive. Some of the technical answers are given, but scattered in the
whole paper and could become an entire section to understand the choices
of authors.


2.2.2 User behaviour in Spotify (Zhang, 2013)

Actually, a research led by Boxun Zhang, Gunnar Kreitz, Marcus
Isaksson, Javier Ubillos, Guido Urdaneta, Johan A. Pouwelse, and Dick Epema
has already been conducted in partnership with the Spotify company. Their
studies were focus on the differences of behaviour between mobile client and
desktop client. In the context of this study, the access of the Spotify Hadoop
cluster has been given to them. This cluster collects and stores all the data
from the users’ actions.
Through this research, several user patterns have been highlighted
depending of the type of data studied. The first data presented in this paper
is the time when a user connects to a Spotify service. We obtain a diagram,
which demonstrates the different peak of connection during the day, such as
the morning peak, followed by a drop of connection during the lunch break
and an other peak of connection between six and seven pm. The interesting
point is the difference of time connection depending of the platform. For the
connection time data, the morning peak on mobile Spotify client is one hour
earlier than the morning peak of desktop client. This difference of user
behaviour has been also noticed for other data such as session length, which
are more regular on mobile than on desktop version.

This research proved a certain interest for the data extracted from
Spotify and particularly between platforms. This research could be performed
by adding a comparison of played style according to each platform. It also

12
Spotify Box University of Kent

proves that the Spotify box represents a concrete interest to extract a new
kind of data, generated from a physical integration of a cloud service.

2.2.3 Other relevant projects

Only a few academic research’s have been conduct regarding the user
behaviour with Spotify, and how to create a new access to these services via
a physical device. However, several projects have been already made by
independent team or developers, and those projects were not structured in
any academic institution. They do not have papers to present them, but they
still are an excellent information sources.

The first project is the work from Jordi Parra [7]. This Spotify box was
his final degree project at the Umeå Institute of Design and offers “to bring
back the physicality of digital music“ (Postscapes, 2013). Focused on the
design aspect, the functionalities have been relegated to a position of
secondary importance. The box actually runs on an Arduino board, which
needs to always be plugged to a computer to access internet, while a part of
the software runs itself on the computer. This project has been an important
source of inspiration regarding the concept which was the direction where I
would like to push my project.

The pi MusicBox describes itself like the “Swiss Army Knife of
streaming music using the Raspberry Pi” (piMusibox, 2013) . The pi MusicBox
project, in contrary to other projects presented in this chapter, is not a proper
musical device based on an embedded board, but is a Raspberry Pi operating
system. This operating system offers a complete solution for those who plan
to create a streaming player on Raspberry PI. After installing and testing it on
my own system, I made the choice to not use it and create my own solution.
This choice has been made on two criteria: the first one was the argument of
total control of the solution. If I made the choice to use this dedicated
operating system, it would be difficult for me to understand all the ins and

13
Spotify Box University of Kent

outs of the software. The second argument was on the performance. The pi
MusicBox operating system has many features which are run in parallel and
are not used in my project. Those features would take the power of
calculation of the Raspberry Pi uselessly contrary to the actual Spotify Box
which runs only its software.

3. Conception

3.1 Overview

Every project, whether a computing project or not, must be attentively
studied during a conception phase. This phase has to precisely define the
aspirations of the proposal idea but also identify its limits. In this chapter I will
present the Spotify box requirements including functional requirements and
non functional requirements. Those requirements are all the features that
the Spotify Box has to respond at the end of the development. I will present
the current limits and constraints of the project and present the software
architecture through diagrams. Finally, I will expose my methodology and
suggest a Gantt chart of the project schedule.

3.2 Objectives

The final goal of this paper is to propose a new solution of Spotify
consuming. Two platforms will be developed, as the main platform is the box
itself. Based on a micro-compute, it will also embed several sensors and
actuators to interact with the user. One sensor will be necessary and part of
the box: the NFC reader. This NFC reader will read NFC tags hidden in classical
CD covers and play their incorporate Spotify track URI via the different tools
provided by Spotify itself. The tags will be managed via a mobile application.

14
Spotify Box University of Kent

3.3 Functional requirements



The functional requirements describe all the functions and
components that will be implemented in the project.

Spotify Box:

- Read an NFC tag, determine if it is a valid tag or not.
- Determine if the Uri is for a track, a playlist or an album.
- If the tag contains the URI for a playlist or an album, the behaviour of the
box should be adapted. In this case, it must request the Spotify API
through the correct end-points. It should then get and analyse the
answered data, and finally extract the list of tracks contained in this JSON
formatted answer. Once the track Uri is extracted, being able to build the
stack of next music to play.
- Be able to play a given track Uri with the Spotify SDK.
- Advertise the user for success or error during the process with an RGB led.

Application:

- Browse Spotify via an embed search bar.
- Write the researched track into an NFC tag.
- In case of unfound track or album, be able to manually write the Uri and
then transfer it to the tag.
- Be able to read a written tag to consult its content, and be able to play a
thirty second preview of the music stored in it.

3.4 Non-functional requirements



The non-function requirements describe how the Spotify box system
is supposed to be to work as expected.

15
Spotify Box University of Kent


Spotify Box:

- The box, has for objective to be as simple to use as possible, and must be
well designed and user-friendly.
- The algorithm, particularly the album and playlist building, has to be
optimised.
- The box must communicate with its user to alert him of the current status.
- The box should benefit a correct network bandwidth in order to request
and play the Spotify tracks.

Application:

- To run the application, the user should have a smartphone Android with
a minimum version of 4.4. iOS devices do not have to be supported
because the NFC readers are not open for developers.
- The smartphone must be equipped of a NFC component.
- The application will need a data connection to request the Spotify API, the
smartphone should have a mobile data or Wi-Fi connections.

3.5 Functional constrains



Spotify offers several tools and platform to allow external developers
to create new services which uses their contents. In my case, I researched
how to play a track from a given Uri and observed that Spotify had only one
SDK for it (except for mobiles), which is not maintained anymore. In addition
of this depreciation of this C developed SDK, it did not support the playlist and
album but only single tracks. This inconvenience was my main functional
constrain.


16
Spotify Box University of Kent

3.6 Project architecture



3.6.1 Use-case diagram

The use-case diagram aims to present an overview of all the
actions available for the final users. This diagram has no vocation to be a
technic diagram, but is accessible to everyone.
Application diagram:











Figure 1. Use case diagram for mobile application

Spotify Box diagram:







Figure 2 Use case diagram for Spotify Box

17
Spotify Box University of Kent

3.6.2 Sequence diagrams



The sequence diagrams, in opposite to the precedent ones, are
technical diagrams. Those diagrams are used as a support during the
development, and integrate all the call between the different components
of the software and their responses. This documentation can also be
helpful if the project is extended by new students, in order to understand
the connection between modules. The use-case diagrams are present in
appendix at the end of this paper.

The first one, 7.1- Sequence diagram of music playing process,
presents all the steps and connections between components to play a
tracks. The second, 7.2 – Sequence diagram of tag managing, describes
how the mobile application works for.

3.7 Methodology

3.7.1 Overview

In this section, I will present the different personal choices that I
made to lead my project. Those choices were made to manage my code
sources, to plan or test my work.

3.7.2 Agile method

Agile methods are new approaches of project management. It
stimulates the software development by using a working rigor. All the
development phase is planned in sprints before starting, and each week I
did a retrospective of the past week to control what was done and what
was not. It also, thanks to its mechanism of iterative work and continuous
improvement, always kept a software presentable and was particularly

18
Spotify Box University of Kent

useful for the early submissions and to present my work during the
meetings. With the agile development, we adopted a reflection without
technical tasks but through use of use-cases/user-story.

In the Spotify box situation, user-story could be for example: the user can
browse Spotify and find a track. In case of error, he sees a popup. To help
me in my project management, I used a tool called Taiga. Similar to a
complex to-do list, Taiga allows to manage a project by user story and
assign a number of point for each task. At the end of the sprint, we can
consult how many points we got and compare it for the previous or next
sprint.

3.7.3 Sources management

To precisely manage my sources, but also to always keep a backup
working copy of each step of the development, I decided to work under
Git by hosting my sources on Github servers. However, using only Git to
host sources was not sufficient for me, and so I decided to divide my work
in branches following the branching pattern of Mr. Vincent Driessen. This
pattern consists of always keeping branches for a proper purpose. It is
divided in five branches: features developments - merging developments
– production – bug fixing – releasing. I kept this pattern and adapted it for
my own usage, by using only 3 branches: features developments, merging
developments and production. Suspicious of the efficiency of this decision
at the beginning of the project, this method has been particularly useful
for the inter-platform development. Since it is not comfortable to write
directly a complex code from a Raspberry Pi due to the lack of recent and
modern IDE, I did my coding from a virtual machine. When the code was
working as expected on this virtual machine, I upload it to the production
branch and was directly downloaded in my Raspberry Pi, ready to be
tested in a real context situation.

19
Spotify Box University of Kent

3.7.4 Testing

One of the particularities of the Spotify box is that the software
will be run on an independent box without any screen. In this context, I
had to certify a working product, whatever the conditions of usage. To
test it during the development phase, I passed my functions into unitary
test operation. Those operations had for objective to highlight bugs or
misconceptions and validate the software. Regarding the functionalities
testing, I chose a restricted panel of people to test the box during a certain
amount of time, with a few music tracks, without telling them any
indications on how to use the box. Those tests have revealed a lack of
information between the box and the user and that feedback has been
integrated in the development as to add a led system to alarm the user in
case of error (Box not connected to Wi-Fi, credentials error to connect
with Spotify, URI not valid).

3.8 Conclusion

The conception phase in the Spotify box has been pertinent on many
points. The first one was to have a complete reflection on the ins and outs of
it, but also highlight the implementation phase such as the complexity of tools
offered by Spotify to access their album. It also has been helpful to take
decisions on how to manage the project and I kept this guideline during all its
development.

20
Spotify Box University of Kent

4. Implementation

4.1 Overview

In this chapter we will see how the system is implemented. For each
component of the complete solution, I will present the technology used such
as the the language but also the library or tools if any were used. Then I will
present how I implemented it, whether it being an algorithm implementation
or the 3D modelling. Finally, I will comment the results expected and the
results obtained, and complete them by how I can improve it for future
dissertations or projects.

4.2 Box

4.2.1 Presentation

The main element of the complete solution is that the box is a mix
between a micro-electronic and a software. In order to respect the main
constrain which is to be usable by the largest panel of people and must have
an ergonomic design. The functionality must also easily to use. This aspect is
crucial in the interest of pursuing our goal to guide the user in his transition
from the classic cd player to the Spotify box.

4.2.2 Technology

One of the constrain assigned at my proposal was the use of a
Raspberry Pi. A Raspberry Pi is a micro-computer released in 2012,
declined now in a multitude of models with different performances. Built
like a computer, it has a CPU, GPU, RAM, USB slots and is able to run an
operating system. Its specificity is to have GPIO pins, which are an
input/output controllable pins by a running software; and I chose to

21
Spotify Box University of Kent

develop this project through the use of a Raspberry Pi 3. This choice has
not been made for its more advanced performance compare to the
previous version, but for its embedded Wi-Fi and Bluetooth chipset. The
Wi-Fi is currently used to request Spotify, yet the Bluetooth technology is
a future objective to enable to do the initial configuration of the box
(Spotify credentials, network settings) directly from the smartphone
paired with the box via Bluetooth. The Raspberry Pi runs an operating
system which is the latest version of Raspbian: A Raspberry Pi adaptation
of the Linux distribution Debian.

The contactless tags which contain the Spotify Uris are NFC tags.
Initially RFID, I changed the techno to switch to an NFC in an objective to
have more compatibilities with smartphones and manage them. The
reader is an Adafruit PN532, driven with its Adafruit python library.

The LED used to inform the user of the current status of the box is
a RGB one, unsoldered from the Chainable RGB Led product sold by
Seeeduino. This Led can be replaced by any classical RGB led available in
the market.

I used a python overload of the initial LibSpotify SDK called
PySpotify. This python library maps and converts each initial C function
into python. I had to develop my own overload in order to create new
functionalities such as album playing, which was for me an essential
feature. To do it, I added, in addition of the Spotify SDK, their API to be
able to request the content of a given album or playlist and then request
each track and build a playing stack.

4.2.3 Architecture

In the objective to create a project reusable for future researches, all the
code has been managed into class. These classes illustrate independent

22
Spotify Box University of Kent

components, which can be re-used from external services (e.g ledDriver,


nfcReader, spotifyApi).

4.2.4 Implementation

As presented before, I designed the code in a way to implement or
change the electronic sensors. I also implemented a similar abstract class
(which does not exist in python) called Reader. This class contains all the
necessary functions to abstract any NFC reader, and in case of the need
to change for a new model of NFC reader, it just has to inherit of this class
and overload the method for this model.

Regarding the initial mechanics of track playing and the incapability to
play an album or a playlist with the given Spotify SDK, I had to make my
own feature. This pseudo code below presents how it was implemented:

/* Spotify Box algorithm pseudo-code */

var uri = read_uri

func check_validity (uri)


IF valid
IF track
queue = []
play_track(uri)
IF album or playlist
get_list_of_tracks(uri) // CALL SPOTIFY API
build_queue(list_of_tracks[])
var next_track = queue.pop()
play_track(next_track)
ELSE
blink_error()

23
Spotify Box University of Kent

The Spotify API is not limited to request basic information of a track or an


album. Indeed, an end-point exists to request additional information about a
track: GET https://api.spotify.com/v1/audio-features/{id})

In a result of a success, we obtain an answer with the complete audio
properties of the given track at the JSON format such as this:

/* Spotify answer exemple */

{
"danceability": 0.735,
"energy": 0.578,
"key": 5,
"loudness": -11.84,
"mode": 0,
"speechiness": 0.0461,
"acousticness": 0.514,
"instrumentalness": 0.0902,
"liveness": 0.159,
"valence": 0.624,
"tempo": 98.002,
"type": "audio_features",
"id": "06AKEBrKUckW0KREUWRnvT",
"uri": "spotify:track:06AKEBrKUckW0KREUWRnvT",
"track_href":
"https://api.spotify.com/v1/tracks/06AKEBrKUckW0KREUWRnvT",
"duration_ms": 255349,
"time_signature": 4
}


At this moment, this is the only way to collect information of a track. We
cannot determine the genre of a music or get statistics about it (such as
its popularity). We remind the reader the research presented in the
literature review chapter where, in the purpose of their research, the
team had access to the Spotify Hadoop cluster (Zhang, 2013).

24
Spotify Box University of Kent

As the box is based on a Raspberry Pi which is a micro-computer, the


software did not start automatically. However, the box was supposed to
be usable without any other device, screen or keyboard. To fix it, I added
cron tasks as the starting time of the box to start the Spotify box program
automatically.












Figure 3 Spotify Box during the prototyping phase

4.2.5 Conclusion

The box was the part in the whole project which revealed the more
difficulties for the implementation. However, this part actually achieves
its target by being able to read a tag, consult the stored Uri and check the
validity of it. Build a playing queue if the given Uri is the Uri for an Album
or a playlist and play the tracks. During the development, I did some
update such as the led, where I had to develop a simple driver to control
it and also tools to connect a raspberry pi to the Kent Eduroam Network.
It has also been a challenge to develop on a Raspberry Pi with restricted
performance compared to a usual computer or server and determine the
process of development to code from a virtual machine and test it on the
raspberry. It also reveals an unexpected potential, which is the data
collection of track played.

25
Spotify Box University of Kent

4.3 Application

4.3.1 Presentation

Not present in my project proposal, I made the choice to develop
this application in the context of a real need. This application has for
objective to be the companion of the Spotify Box user. This application
should be able to complete three functions. The first one being through
the Spotify API, browse the catalogue of tracks and find the user’s
requested tracks, display its information and write it into an NFC tag. The
second function is specific if the user can not find its track via the
embedded browser, he must be able to write the Uri manually in a form,
and transfer it to the NFC tag. Finally, the last function is to manage the
tag by being able to read an NFC tag, consult its content and details of the
track, and play thirty second preview of the track form the application.

4.3.2 Technology

For the purpose of creating an application available on iOS and
Android, I developed my application with Ionic. Ionic is an SDK to create
hybrid application with high performances and as Ionic embed Cordova
and Phonegap, it allowed to use all the native components of the
smartphone, like in my case the NFC reader. The front part of the
application has been developed with the framework Angular.JS which is a
framework MVW (Model – View and Whatever works for the developer).

To read and write the NFC tags, I used the open source phonegap
library “NFC Phonegap” developed by Mr. Don Coleman.
I implemented the code around the service’s logic. I created factories
type, one for the NFC reader and the other for the API. They could be

26
Spotify Box University of Kent

instantiating only once and encapsulate all the methods to manage their
features.

4.3.3 Architecture

As noticed before, the Angular framework respect the MVW
pattern. This pattern is composed of three elements:

Model: The model structures the data. It makes the interaction
between the data storage solution (MySQL, NoSQL and any other
database systems) but can also manage this data and reformat it.

View: The view is what the final user sees. The view is composed
of Document Object Model (DOM) which are externally managed
and updated. The view does not have an algorithm, but the
algorithm manages the view. In our application, the view is written
in HTML.

Whatever works for the developer: This third element is
controversial. Indeed, the Angular.JS community is divided to align
the framework to the MVC (Model View Controller) pattern, when
others want to align it with MVVM (Model View ViewModel). In
this context, and due to the flexibility of this framework, the
community names this third element “Whatever works for you”. It
could be service-methods and factory-methods to manage API,
routine or even filters to reformat the data.




27
Spotify Box University of Kent

4.3.4 Implementation

The code is divided in four groups. The first one represents the
view and englobes all the HTML files. Those HTML files are the design that
will be viewable for the user. The files to be dynamic are linked to an
assigned controller. This controller written in Angular.JS control the DOM
of the HTML page. The filters are functions which are used as tools to
reformat the data and finally the services, which are represented as
independent tools that can be called from everywhere and are fully
abstract.

4.3.5 Conclusion

Initially not scheduled to be developed, this application was
indispensable to propose a complete functional and usable solution. One
of the feature to add to this application could be the pairing with the box
via Bluetooth and be able to configure it.

4.4 3D printing

4.4.1 Presentation

In order to prototype rapidly the box, to validate the choices, and
propose a proof of concept, I decided to print it. This choice has been
made for several reasons. The first one being the quality of the final
product, comparatively to other fast prototyping methods like CNC. The
second method was the prowess and challenges to design the box to be
printed with this technology, and the last argument was the availability of
3D printer at the Shed.

28
Spotify Box University of Kent

4.4.2 Technology

The 3D printing consists of a deposit of material to create three-
dimensional objects. The objects’ plans are designed with 3D modeller
software, and the final model is analysed by the printer to determine how
to deposit by layer the material.

4.4.3 Software

Two software have been use to print the Spotify box, the first one
being the 3D modelling software. I decided to use the 123D software by
Autodesk for its Mac compatibility and its user-friendly interface.

The second software was Cura, which is the software that prepares
the model for 3D printing. It also allows to setup a large panel of settings
to personalise the printing and increase the productivity, reduce the
printing time or also reinforce the strength of the final object by adding
more layers.

4.4.4 Modelling

As I am not an expert in this domain, I had to start from an
existing model. I chose to base my design on the Macintosh design and its
adaption for Raspberry pi: The Raspitosh project. Then, I modified to
adapt it for a Raspberry Pi 3. I also made several modifications in the
disposition and add a 3D printed support for the NFC reader.



29
Spotify Box University of Kent

4.4.5 Conclusion

Thanks to the Shed, its staff and the resources of the University of
Kent, the box has been printed in two days (33 hours exactly). Despite the
few misconceptions, the final casing of the box offers a finish with a
professional aspect. This technology allows us to rapidly confirm the
choices and obtain a functional prototype. The future printing for example
of a second version of the Spotify box could be better, particularly around
the cables management, to obtain a perfect 3D model adapted of the
Raspberry Pi 3 and the NFC PN532 reader.

Figure 4 3D model of the Spotify Box

30
Spotify Box University of Kent

5. Tests

5.1 Overview

The tests are the opportunity to confirm the value of the initial idea
and validate the stability of the final product. The Spotify box has been
presented to two categories of tests. The use-case, to validate the
accessibility of the Spotify to non-technological persons, and software tests
to certify that the Spotify box is able to respond in every case possible.

5.2 Use-case tests



To conduct this first test of usage, I selected a restricted panel of
people who are close to me, in order to rapidly get their feedbacks. A better
test should be run with a new panel of people which could be determined
according to gender, age and IT background. The use-case test aims to
reproduce each of the use-case diagrams. All the tests have been succeeding
but one feedback has been highlighted, which was the lack of interaction
between the box to the user. To correct this need, I had an RGB at the top of
the box, in order to set the current status and display a signal in case of error.

5.3 Software tests



The software aims to validate each components of the global
software. To do it, each function is independently tested out of the complete
software. We give it several arguments and attributes, valid it or not and
observe its behaviour. The correct implementation of this unitary test has
been complex to integrate due to the material aspect of the product. Testing

31
Spotify Box University of Kent

if the NFC reader works properly or if the RGB led is set on the right colour, it
needs human intervention which is contrary to the test automation.

5.4 Conclusion

To conclude, the test which are to test the validity of the concept on
one hand or the validity of the code on the other hand, has entirely complete
their functions. The first category highlights a huge needed feature which has
been added after those tests, and the second allows during the development
to maintain a working software.

To perform these tests in the future, the complete strategy has to be
re-thought about to increase its accuracy.

6. Summary

6.1 Completion of objectives



The realisation of this project has produced a functional and
innovative device. The actual version of the box is able to consult the content
of an NFC tag and play the corresponding track, and in case of error, will
advertise the user. If the given Uri is an album or a playlist, the Spotify API will
be requested to deliver the complete list of track in this album. Then, those
tracks will be stacked in a queue of music to play. The main objective of
delivering an innovative box have been successfully completed, and we
remind the reader that a video which presents the box functionalities is
available at this address: http://bit.ly/2bVPDMp. The second, that was
studying the data and extract user behaviours from them, had to be reported
for future research. The main reason is the accessibility of the resources which

32
Spotify Box University of Kent

are actually not available via the API, but only by using the secured and private
Hadoop cluster of Spotify.


6.2 Future directions

6.2.1 Box

The current prototype of the box and the design of the software
allows the addition of new features. The actual sensors are quite
expensive. A cheapest version of the box could be developed with the
cheaper NFC reader and make the box easier to duplicate. To do it, the
interface NFC reader could be inherited and let the future develop and
adapt the current methods to the targeted sensors. The current version
of the playing does not need upgrade, but can be completed by additional
features such a button available on the box or use an NFC tag to play the
top played tracks or the top ranked artists.

6.2.2 Application

The current application has been developed with the framework
to make it cross-platform. The first amelioration could be the recode of it
in a native language. This new development will increase the
performances of the application, particularly the component access which
are slower through the framework. The second major improvement for
this application which could be developed is the addition of a setting tab.
Paired with the box in Bluetooth, this tab would contain complete settings
panel such as the Wi-Fi set up, the configuration of the light colour or the
Spotify user credentials.

33
Spotify Box University of Kent

Finally, the last improvement to do on this application would be


the user interface, which deserve a better reflection on the user
experience and the user flow. Beyond the user experience, a global
improvement about the design has to be done.

6.2.3 3D printing

The 3D printing was executed in order to fast prototype the box.
This technique has been entirely satisfying and proved the viability of the
project concept. However, several misconceptions are existent in this first
version of the 3D model and have to be corrected. The main
misconception is situated around the connectors. Indeed, the current
design is blocking the cables output and I had to adapt them and use
angled cables. The second point that could be perfected is the integration
of the NFC reader. In the current conception, I had to modify the
Raspberry Pi stand and make cuts in the stand’s arms.

6.2.4 Data mining

The Spotify box is the physical gate to a new type of data. Several
researches has studied the usage of Spotify but never with a physical
player. This Spotify box can be used as a tool for future researched and
add a data collection. This data collection and mining could reveal an
unexpected difference or points of interest like the music style played
with the box, the time of usage and in general the difference of usage with
the classical Spotify clients.

6.3 Final conclusion



The Spotify box was a formidable experience and the beginning of a
beautiful project which now needs maturity to improve and be tested.

34
Spotify Box University of Kent

Despite the data mining part which has not been implanted in the short time
given to realise the project, all the others parts are implemented and
functional. The application has joined the global solution, which was not
initially scheduled to offer a complete solution to final users.

Beyond the research and innovative aspects of this project, it was also
a great personal experience. Designing, managing and developing from
scratch and seeing it evolve to a working product despite the obstacles (e.g.
the changes of contactless technology and the difficulties to use the 3D
modelling software) improved my personal knowledge. Though, I had to
manage my development time to respect the deadline and determine an
incremental methodology of work to be able to present a working prototype
at every meeting with professor Kampouridis.

This project also bound me to learn how to create a mobile application
with the Ionic framework, and I had to learn in the same time the language
Angular.js. It was also the first that I did it entirely in python.

35
Spotify Box University of Kent

7. Appendices

7.1 Sequence diagram of music playing process


36
Spotify Box University of Kent

7.2 Sequence diagram of tag managing


37
Spotify Box University of Kent

Bibliography
[1] McKinsey & Company. (2015, September). Global Media Report. Retrieved
August 28, 2016, from
https://www.mckinsey.com/~/media/McKinsey/dotcom/client_service/Media%20a
nd%20Entertainment/PDFs/McKinsey%20Global%20Report%202015_UK_October_
2015.ashx

[2] Statista. (2016). Number of global monthly active Spotify users from July 2012 to
June 2016. Retrieved August 23, 2016, from Statista:
http://www.statista.com/statistics/367739/spotify-global-mau/

[3] Statista. (2016). Number of paying Spotify subscribers worldwide from July 2010
to March 2016. Retrieved August 23, 2016, from Statista:
http://www.statista.com/statistics/244995/number-of-paying-spotify-subscribers/

[4] thephygital. (2014). The phygital. Retrieved April 15, 2016, from The phygital:
http://thephygital.com/

[5] Lochrie, M., Burnett, D., & Coulton, P. (2013). Using NFC check-ins to crowd
curate music preferences. Near Field Communication (NFC), 2013 5th International
Workshop on. Zurich, Switzerland: IEEE.

[6] Zhang, B. (2013). Understanding user behavior in Spotify. INFOCOM, 2013
Proceedings IEEE. Turin: IEEE.

[7] Parra, J. (2011, 02). Spotify-box. Retrieved 09 06, 2016, from Zenona:
http://zenona.com/work/spotify-box/

[8] Spotify Box. (2013). Retrieved 09 06, 2016, from Postscapes:
http://www.postscapes.com/spotify-box/

[9] Pi MusicBox. (2013). Retrieved 09 06, 2016, from Pi MusicBox:
http://www.pimusicbox.com/

[10] Mopidy. (2013). Retrieved 09 06, 2016, from Mopidy:
https://www.mopidy.com/

[11] Göthner, F. Identifying Patterns in User behavior in a Music Streaming Service:
A Cluster Analysis Approach, (2015). Stockholm, Sweden.

[12] Turner, T. (2012, 10 05). The Modern Jukebox. Retrieved 09 07, 2016, from
yankodesign: http://www.yankodesign.com/2012/05/10/the-modern-jukebox/

[13] Göthner, F. Identifying Patterns in User behavior in a Music Streaming Service:
A Cluster Analysis Approach, (2015). Stockholm, Sweden.

38
Spotify Box University of Kent

[14] Meier, F. Fink, M. Zolzer, U. The JamBerry - A Stand-Alone Device for Networked
Music Performance Based on the Raspberry Pi, (2014). Hamburg, Germany.

[15] 123DApp. (2015). Raspitosh, Retrieved 09 06, 2016, from 123DApp :
http://www.123dapp.com/123D_Design/Raspitosh/4019973

[16] Driessen, V. (2010). A successful Git branching model, Retrieved 08 07, 2016,
from Nvie : http://nvie.com/posts/a-successful-git-branching-model/



39

You might also like