iOS Swift Tutorial: Stream Music from Spotify

hi and welcome to another very exciting tutorial today we’re going to have a look at the Spotify iOS SDK which is still in a beta phase but nevertheless we’re going to have a look at the functions that we can use and how to integrate that into our own apps and how the user authentication process works so that you can integrate this into SDK with your apps and play around with it and explore great ideas that become possible with the Spotify SDK so as you can see here we have a little demo application where only a Spotify login button is displayed you can get this login button from the developer page or Spotify and I’m going to show you what happens when I click on this button so let me click on it and as you can see we’re moving to a Safari window where we can connect our tutorial one app to your Spotify account the important thing is for you to play music and to stream audio using the Spotify SDK you need a spotify premium account which is free for 30 days so if you want to play around with it and get this 30 day free period and if you have already a spotify premium account you can of course use that so let me click a login and enter my credentials and once I press the login button as you can see we come back to the app and playing some music and of course you can also let me quit that of course you can also see some some background image where the actual album art is displayed so this is what we are going to create and well now let me show you what kind of stuff we need in order for this to work let’s first of all open Safari and let’s search for the Spotify SDK so Spotify iOS SDK and there we go and please note that here it says it is important that the iOS SDK is currently a beta release the content and functionality of future versions is likely to change significantly and without warning so keep this in mind and always have a look at this Spotify page here and you’re good to go and you have to implement the changes of course but I think it’s worth having a look nevertheless so what we want to do first is actually download the SDK as you can see here here’s a download button and we can download the latest iOS SDK version which is a beta 6 and we can get this from github so let’s go ahead and download the source sip file and let’s go back and what you also need to do is create a developer account for creating an API key or secret and a client ID and to do that what we want to do is clicking on this tutorial and examples and provide we provide a beginner’s tutorial which you can find here and also here is the beginner tutorials button and we want to scroll down here to creating your client ID secret and callback URI which is a very important part and I’m going to explain that in a second so let’s click on my applications I’m going to open that in a new tab since we need both sides in a moment and as you can see I already created a developer account which has its to this tutorial one app so what you want to do is click on create an app and enter an application name and application description and click create after you have created this developer account which is not necessarily a premium account so you can do that for free and now once you have created your app let’s click on it and you could also enter a website but the most important thing actually is here at the bottom which is the client ID the client secret and this redirect URI and as you can see this looks like a an on-air URL except for the protocol here at the front which is spotify tutorial so you if you add an uri as you click on add your eye and then you could say something like your app name column slash slash so this is actually the protocol that you’re going to use in that we need to listen to within our iOS app so that we know once we come back from the spotify login page as you have seen earlier we are going to open a safari window where the spotify login is displayed and once you click on login you will be rounded back to your to your application and the application needs this URI to to receive the additional information like the session that Spotify is going to give you so we’re going to call that return after login to identify the process that is going to happen so you click Add and don’t forget to save this and once you have done that we can go back to the Spotify tutorial and scroll down a little more and as you can see

here we have to set up a token exchange service and to do that we are going to install some some ruby stuff and some some server stuff because this token exchange service is nothing more than a small HTTP service called a token exchange service and so that we can use it you have to copy this command sudo gem install Sinatra encrypted strings so copy that and open your terminal and once you’ve opened your terminal you can simply paste that command to your terminal hit enter and enter your password and that’s it so I have already installed that so I don’t have to do that but what we also need is a little piece of software so which we can get here in order to deploy this who wrote here oh cool stuff we click on the example come to a github page where we can download the Spotify token swamp service dot RB a ruby file and we’ll simply download that as well and configure that in a second so let’s move both the spotify token swamp master folder that we’ve downloaded and the iOS sdk better to our desktop and now let’s extract from this spotify token swap master this Ruby file and also drag that to the desktop and then we can actually delete and the rest of that stuff so let’s just get rid of that and here is our spotify token swap file which we are going to open and as you can see let me just bring that to the side and as you can see here there are some placeholders we can also delete all these comments here which tell us where how to activate the service connecting to localhost column one two three four which is the part swap um so let’s just delete that to give us some more space here and now what we are interested in actually is first of all uncomment this this line so that we set this part to one two three four and also we are interested in these three lines client ID client secret and callback URI and as you might have already guessed we are going to get this stuff so it’s close this github page from the Spotify developer from the de Spotify developer page and there is our client ID and client secret so let me just copy the client ID and paste it here to client ID and let me copy the client secret and also paste that here and also copy the redirect URI and paste that here so this is all and let’s save that file and this is actually all the preparation we need for this a Spotify token swab file so we can close that now but what we need to do is open up a terminal again and what we want to do here is now run this run this file so we will type in CD to change the directory and go to our desktop where it is located and now we simply write Ruby Spotify a token swap and hit enter and now the service is running it’s running and now we can actually go to our Safari and type in localhost 1 2 3 4 and as you can see this Sinatra server is running so let’s close that let’s also close this this tutorial here and um is there something else I don’t think so so now we can also close the file and prepare our our Xcode project so let me move this to the side and now let’s create a new Xcode project which is going to be a single View application so hip next this is going to be let’s say your spot to find demo we won’t use core data this can be universal app so click next and create that on the desktop and first of all what we need to do is have a look at the iOS SDK 6 folder and there is our Spotify framework which we are going to use so let’s move that to our project and don’t forget to select copy items if needed so this that this is a part of our project and finish this and now we can close that and now let me just resize my window here and let’s zoom in a little to the bottom and as you can see here we have linked frameworks and libraries Spotify framework is already a part of it and what we also need is going to be the a/v foundation framework so let’s select

that and add that as well and as you can see here now we have the a/v foundation as a linked framework and as you remember we also talked about these callback you are eyes on and and we have created this callback URI in the Spotify developer section and to make the corresponding changes in our project we’ll have a look at our info tab here at the top of our Xcode window and have a look at the URL types and what we want to do here is pretty simple we want to add another URL type so let’s give this an identifier something like conduct training dot Spotify authentication something like that and the URL scheme is the Spotify tutorial and this is pretty important so let’s let me hit enter here everything we enter here is going to be placed into the info.plist of your project so this URL scheme is actually the same as we have as a callback URL here and as you can see this is everything from the start to the colon and this is really important that they are exactly the same so the URL scheme needs to be exactly the same as the callback your eye protocol name everything before the colon all right so this is the this one modification next modification is going to take place in the build settings and here are some here is some huge stuff so we don’t even need basic we need everything and we’re going to use the search here and look for other linker flags and what we are going to need is the linker flag objective-c so let’s add – objective-c so this is one linker flag that we need to set an auto phone to use Spotify framework to work properly and now we can move on to import the Spotify framework and since this framework is written in objective-c what we need to do is create a bridging header so let’s just select the view controller that Swift file create a type command and only keyboard and let’s create a new cocoa touch class it can be a view control or whatever actually and but make sure you select Objective C click Next and create and now Xcode is going to ask us if we want to create a Objective C and Objective C bridging header we say yes and there we go there’s our Spotify demo bridging header and now we can actually delete those two objective-c classes or class files that we have just created the header file and the implementation file and simply delete them move them to trash and now we can work with our Spotify framework and import that here so let me zoom in a little and what we want to do is want to import a Spotify slash Spotify dot H and actually that’s it now we have all the preparations ready and we we can use our project to work together with Spotify and we can now think about the user interface which is actually pretty simple but let me show you where I can get this Spotify button so let’s open Spotify developer and there is um oh where is the design resources here in the Left bar and now we can download their design resources as a zip file and let’s open our images assets folder here in the left on the left side of our execute project scroll down here and add another image set we’re going to call this image set let’s say a login button and for simplicity sake here are the Spotify buttons and here let’s say login with Spotify PNG and there is this mobile file so let’s just enter that for all three sizes you could actually adapt them to the correct screen size but I will simply use this size now for all of them go to our main storyboard and let’s add a button so here is a button and what we want to do with this button actually is first of all remove the text and then change the image to the login button and there we go let’s place that in the center and now we’re going to use some auto layout constraints to make sure it is always positioned in the center on every device so press ctrl key on your keyboard and drag from the button to the view and select Center horizontally in container and center vertically with the shift key pressed and then you can

simply add press Enter and as you can see there are auto layout constraints and I will bring up the assistant editor and first of all we will create an outlet for this button which is the login’ button and also will create an action so again control drag and we’ll say this is going to be an action and sale login with Spotify alright so this is going to be the first thing we want to do we want to login with Spotify so let’s close the assistant editor enter our viewcontroller and zoom into our login method log in with Spotify and if you remember the demo I showed to you earlier about logging in with Spotify you saw that we have entered Safari so what we need to do actually is create a URL that will open a Safari window and to do that we will first of all create an authentication object and use the SPT authentication class and it’s default instance and now we can create a login URL and using the this authentication object and say login URL for client ID declared um redirect URL and scopes and now you can see that there must be some kind of client ID and we need a declared redirect URL and therefore we’re going to create some constants here at the top of our view controller class and let me first create these constants with a leading k4 constant which is first of all the client ID and this is going to be an empty string for now and then we are going to need the callback URL we will also need the the token swap URL for the token exchange service and also we are going to need a refresh service so k token um refresh service your L which we are going to use since the sessions that we’re going to create are about to expire from time to time and we need to refresh them and to enter the client ID I will simply use our Ruby file that we have here the spotify token and copy the client ID and zoom in again as for our callback URL you know we have created this callback URL at the spotify developer center so let’s enter the spotty fine tutorial toriel colon slash slash return after login I actually could also copy that from the from this file so that I don’t make any typing mistakes so this is that and now let’s move on to the swap URL and the swap URL is actually our server that we set up or using the Ruby file so this is going to be HTTP colon slash slash localhost the port wants one two three four and for the swamp service we’re going to use slash swap and for the refresh HTTP colon slash slash local host part one two three four and here we are going to use refresh this is all part of this file that we have customized earlier where we entered our client ID client secret and callback URL and now that we have that we have all of this information we can move on to our login button again and can enter here our client ID which is simply BK client ID the declared redirect URL is we have to create URL from from that string so this is going to be the K callback URL and the scope of our of our for this for this login URL is going to be as you can see it needs to be an area so let’s make some brackets here it’s going to be SPT authentication streaming and the authentication streaming scope and that’s it actually there is our that is going to create our log in URL and now we can simply use UI application shared application and now open a URL and this is of course our login URL and now I can run this application for the first time and as you can see there is our Spotify button and once I click on the log in with Spotify we will be redirected to to the Spotify web and we can connect our tutorial one application to our Spotify account once we click on login we can enter our

credentials but if we were to click on login nothing would happen yet even if I would enter the correct credentials since Spotify is going to try to call our callback our app and give it some more information and to receive this information we have to go back to our app delegate since in the app delegate we can use a delegate method that can listen for URLs that are that are used by a Spotify and other services when calling back our our app so first of all let’s copy this these these constants here and also paste them here into our app delegate and into our app delegate Swift file and let’s now add this this delegate method which is called application did open with your with open or L source application and annotation and the first thing we need to do here is check if the URL that we are we are receiving is a Spotify authentication callback so we’ll use an if statement again you see SPT authentication class and it’s default instance and now we’ll ask if this you if we can handle this URL which is the which is this URL here with declared redirect URL which is our callback URL so again we have to create a URL from our strings ons URL our parentheses string and this is GK callback URL and now if that is the case so if we can handle this as if we can handle the URL that we are receiving we also know that we have received an authentication callback that we can now handle and with this authentication callback we can create a lock-in session so let’s again use the SPT authentication class in the default instance and this time let’s use the handle authentication callback with triggered authentication URL and again we are going to use this URL we are getting from our delegate method so this is URL and now it asks for the token swap service endpoint at the URL and this is actually the token swap service URL that we have predefined here so again let’s say ns and as your L from a string URL with a string k token swap URL and I will simply add this callback so it requires us to enter an error so anna’s error and here is the interesting part which is the session object which we can use later to identify our app as an authenticated app that canden is allowed to play music that is allowed to use the spotify premium services so again here session is going to be an SPT session object let me zoom out session SPT object alright and now let me just enter return false here to get rid of this error and what we want to do here now is actually first of all check if there was an error since we have an error object here we can also use it and check if there was an error so if error not equal to nil so there is an error in this case we can print line authentication error and type in return so that the function breaks off and doesn’t it continue with running the code that is below that return and now that we have this session we should do something with it and we can actually use the session and save it somewhere and where is the best place to save it and how is the easier what is the easiest way to save this actually we can use and is user defaults for that and let me just give you a little introduction to nsuserdefaults which are quite handy to use and is user defaults we have to create a user default object so user default and we use nsuserdefaults standard user defaults and this is used for little amounts of data that have a key and the value actually much like a dictionary but what we can do here is we can say set bool for key for example let’s set this to true and let’s say premium purchased whatever and we now have sent what we need to do is actually synchronize this this is actually something like safe and what this does is it saves in this user default section of your amp it saves a value and the key

for premium purchased in this case and you could use that too to save some little information when you have inner purchases in your app and someone has purchased something then you can set this rule to true and you can then use something like that if user defaults bool for key premium premium purchased then some kind of function display premium stuff something like that but I think you get the idea and the only problem with user defaults is that you have to that you’re pretty confined to the to the types of values that you can set as you can see can set a bool double float integer and object and URL maybe also no no string but as you can see you can set an object but you can set a session object into this into this user default this just won’t work but we can set an object to in using these user to false but we have to take a little side way to get this done and what we need to do to make this happen is we will keep this user defaults here but we will convert our session object into a data object so let’s say we have session data and now we can use a so called and it’s keyed archiver and use it to archive data with rude object and our route object is actually our session object and this gives us a data object and now we can simply use our user defaults and set an object for a key and we will simply use the session data for the keith spotify spawns but if i session and then synchronize that and then this is done and we have saved our session and can now work with the session to listen to music for example so now that we have completed this authentication process we can go back to our to our view controller and make this somehow visible to our users that the login was quite successful and let’s therefore add a notification and viewdidload so that we can fire this notification once the login process in app delegate is completed so let’s use the NS Notification Center and the default Center and add an observer for our uh view controller so let’s enter self and the selector that we want to call the function let’s call that update after first login and the name is going to be lets say login success for and we don’t need an object here and now let’s implement this function so let say directly under the view load don’t need the notification object so this is an empty function here and what we want to do actually is hide the login button as soon as the login is successful so let’s say again button dot hidden equals true and let’s say if we launch the amp bystander let’s say that the login button is also hidden and only if we don’t have a session let’s show this login button so therefore we will again use the user default so let’s create a user defaults object which is NS user default standard user defaults and now we can check if the user defaults well let’s do it a little different let’s create a session object directly so if we have a session object which we have to explicitly type as in any object and we can we can set a huge our user default object for keys fortify session to it then we obviously have already a session so let’s make a comment here session available and if this is not the case then we haven’t logged in yet and then we can we can display our buttons so login button hidden equals false and now

we can just have a look at that and give it a go so there’s our login button so obviously we don’t have a we don’t have a session yet so I press login I get to our to the spotify website i press login enter my user credentials and after i press login we will be rerouted back to our application after allow that and as you can see nothing happens yet since we did not fire the the notification so let me just do that and complete this notification name which is login successful and we want to do that in the app delegate after we have saved our session here so let’s say Ana’s Notification Center default Center post notification with a name and this is the name and we don’t need an object here but if I run the app again now you can see that the that your login button is no longer present but let me reset contents and settings here of our simulator and run the app again so that I can log in again and login to Spotify my credentials and there we go as you can see there is no button there and more next up we have to think about the refreshing process because as I’ve told you from time to time your session expires and we have to refresh it so let’s go back to the view controller since buted load is a pretty good place to check it so every time you launch your app again we check if the session is still valid and if the session is available what we need to do is first of all convert this session object back to a SPT session object since this is at the moment and any object a data object actually so let’s first of all create a session data object constant and and convert the session object to an NS data object and now we can create a real session object session equals and now we will use the NS keyed an archiver and call an archive object with data and use the session data object for that and now that we have a session object again we can use a pretty it’s also cancer to SPG the session object and now that we have this session object we can now check if the session is valid is valid so and if it is not valid so let’s add an exclamation mark here at the front and if it’s not valid we want to we want to refresh it or renew it as a Spotify consent so let’s use the SPT education object again at the default instance and now let’s call renew session with service and point and a call callback URL and the session is the session that we just received with the service and point and this is actually again au a URL so nsurl with a string and we will then use the que token the string que token refresh service URL and we have a callback here so let’s again use that there’s an error and as error and also there is the session so this is going to be the SPT session object and now that we have that we can again check if there was an error or if there was no error so if error equals nil we can continue and now let’s add this new this renewed session to our to our user default so that we can use it throughout the app if you would if you would have different view controllers this could become really handy so it’s Luis use user e false said object first of all we would need to create an session data object again so let’s say session data and again use the NS keyed archiver archiver and archive data with root object and this would be the session itself and now we can use our user defaults send object session data for key Spotify session and let’s don’t forget to synchronize your user defaults synchronize and and let’s also create a session object here as a property so of our session it’s going to be SPT session and here we go this is our session and

now we can say self dot session equals session and we also want to call a play function here play using session we’re going to create this function in a second and let’s say if there was an error let’s say else and print line error error refreshing session and if there was no if the session is valid we have to go to this if statement say else let’s print line session valid and also call the play using session function here and actually that’s it now let’s um let’s go to the play using session function that we’re going to write and this is actually the fun part since we now are about to play our first piece of music so let’s say play using session and there is a session session object let’s say and this is going to be SPT session which is no optional value and now in order to play music what we need is a player so let’s scroll up and beneath the session let’s also create a player which is an SPT on your stream control which we’ll declare as an optional and once we return back to our plane using session function we will first of all check if our player is nil so if it is want to create it so player equals SPT streaming controller and we want to initialize it with a client ID which is our constant client ID so now we have created and player um and what we want to do now is actually log in using our sessions so let’s say player login we session and callback so there is and we will use our session object and a callback and here we go there’s only an error and s error and if the error is not equal to nil we can say print line enabling play back got error in this case it makes sense to see what the error actually is and print this and also return here so that the function does not continue and the first thing now we want to do is play a demo album which is also stated in the tutorial that is that is was prepared from Spotify and now we will use a so-called SPT request and request an item at URI and this URI is actually again a URL and we will now and say Ana’s URL with a string and there is a special format about the Spotify your eyes so what we do is Spotify column album and I’m going to copy now the album identifier so let me go back to Safari and let’s go through the iOS SDK and the beginners tutorial and let’s scroll down um and there should be somewhere and there it is there is the Spotify album with its with the identifier so let’s paste that here and this will play a whole album for us so let’s say with session and we’ve got our session object here and we again have a callback here so let’s use int and there is an error and as error and and any object and this object will give us the album itself so let’s use this again as in any object and and we will cast that now to an to an album in a second after we have checked for the error if error not equal to nil what we want to do is again print line arm album look up got error and again the error here and return and that’s it and now we can cast this any object that we have here which is now an a real album object and all let’s do it the other way around let’s say album

object here and this is going to be an album and now let’s say album object as SPT album and now we can use our player and say play itself since we are in a in a closure we have to use self dot player and then we say play track provider and E track provider is our album and now the callback is going to be nil and then let’s go back up to our unit load method and also played a session and actually it makes a lot of sense changing the name here since we have multiple session objects here let’s call this one renewed renewed session and let’s set self dot session tutors renewed session and now let’s say self dot play using session with this renewed session and um here again we can simply use this the session object since it is valid so let’s enter session here and that that’s it actually now let’s give it a try and run the app and as you can see session is valid and there’s our music and this is actually the demo album and now let’s also handle this update after first logon since this is a very important part so that also the music plays when you and when you enter your user data for the first time and use the app for the first time so what we want to do here is again create a user default objects user default which is NS user default standard user defaults and if there is a session object that we can use which is going to be in any object let’s say user defaults object for key this is a Spotify session and now if this is the case if we have a session object we can create this session object or a session data object is going to be a session object as NS data and now we use the NS keyed on archiver so let’s say first time session it’s going to be an is keyed an archiver on archive object with session data object and now cast that to an SPD session and now all we need to do is play using session first time session and now it also works when we have when we have created when we have just launched the app for the first time and entered our user credential for the first time and so on so now what we also want to do is actually displaying some album art and also what we want to do is playing this as soon as the the playback begins and to check if the playback begins what we have to do is adopt a protocol so let’s scroll up to the top and use the SP team audio streaming playback delegate and now we’ll scroll down a little and add a delegate method here at the bottom which is audio streaming did um let me do that again audio streaming did start playing track and what we want to do here is update cover art and in order for this to work for this audio streaming they’d start playing track method to be called we also need to set the delegate to our player once it’s initialized so let’s say player dot playback delegate equals self and now let’s create this update cover art function let’s say here just beneath the login with Spotify let’s say update cover art and this is actually pretty simple stuff but before we can do that and before we can update cover art let’s adjust our user interface a little and to show this cover art we’ll simply use an image view drag that to here and

make its size 600 by 600 600 600 and now we can simply drag that to the top left corner and let’s place it beneath the button and now we can add our layout constraints again which is pretty simple press shift on your keyboard leading space training space top space bottom space and this should do it this will this will make this image view exactly the same size as the view itself and what we also want to do is adjust the image mode so that it is scale of aspect fill and now we will simply add an outlet for the this artwork imageview so let’s add an outlet here with the assistant editor artwork artwork image view and now we can go back to our function to implement this update artwork and what we want to do here is check if our player and its current track meta data is equal to nil because if it’s the case and this is nil you want to display an empty image so let’s say artwork image view image equals an empty UI image all right and we can return and do nothing else and since we need a session now let’s also make some adjustments to to our viewdidload method again first of all and if our session is still valid we can use self dot session equals session since this one is going to work and it is valid we can use that and also here for our first time session let’s also say self dot session equals first time session so that we can use that and now let’s go back to our update cover art function and what we want to do now is actually creating a URI that will ask for a specific cover and for the album cover and we will use our player and access player and access its current track metadata and this is actually an a dictionary so we can use a key that is called SPT audio streaming metadata album URI as string and now we can use the SPT SPT album and say album with URI and now we can enter an nsurl with a you string which is the URI and a session which is simply the session and a callback where we have an error and this error and a an album object which is defined as any object here so let’s first cast this album object to a real album so album object s SP T album and now we can say if let image URL equals album dot largest cover dot image your LS nsurl and also unwrap that so if this works and we get an image URL what we want to do is first of all dispatch this asynchronously so that we download the the album image in the background so let’s say in dispatch any synchronously with a dispatch get global queue with identifier which is going to be dispatch queue the priority default just this one and the flag of zero and there’s our dispatch block and now we want to create an error object which is an NS error which needs to be optional and we set it to nil and we also want to create an UI image object so cover image equals UI image and now we can say if let image data equals NS data contents of URL and then we are going to use the image IMG URL the options are going to be nil but our error object

is going to be entered here so that we can check if there was an error but we don’t have to of course so if if era equals nil so if there was no error let’s bring that in there if there was no error what we want to do is say cover image equals UI image with data image data and add an exclamation mark here so that is unwrapped this should make the Eric go away and now after we have we have done this background stuff we can return back to the main queue so let’s say this patch asynchronously and this time on the main queue dispatch get main queue with a block and and what we want to do here is simply say self dot artwork image view dot image equals cover image and that’s it so now let’s run the application again session is valid and as you can see nothing happens music plays but we already have defined the did start playing track delegate method but we what we have to do of course is update the cover art as soon as this track starts playing so let’s do it again and there it is there’s our cover art and that represents the album that is playing at the moment now since this is the the easiest way I could show you how to play music I want to show you now how you can play custom music since here we are playing a demo album and you need a album identify here I’m going to show you now how you can search for a certain custom pieces of music so let’s comment this piece out and do another SPT request where we can enter a custom title for a specific song that you want to listen to so what we want to do is again create peaty request and this time we want to perform a search with query query type offset and so on let’s just use that and a search query let me say it’s going to be let it go which will play this famous Disney song the query type is going to be an SPT search query type of type query type track we don’t need an offset so let’s say zero we don’t need a session for that so let’s give that nil and now we have here an error has in the callback and the any object is actually the results that we get from the that we get from this from this query so let’s say any object here any object and what we need to do now is working with this with this result so this result object that we get here is actually a so-called SPT list page so let’s create a track list page and convert your result as SPT list page and now what we need to do is get a so called partial track so let’s say partial track equals track list page dot items so this gives us all the items that we receive from the from this query for simplicity’s sake i’m simply use the first object here and hope that it will play the song that i’m looking for but you would have to analyze that in a productive environment so that you can check if this is really to search a song that you queried for so and I’m going to convert that to an SPT partial track and now I can request an item saying SPT request request item from partial object and the partial object is this partial tract that I have to generate it here and we won’t need a session here either and we have a call back here again with an era and this era and in this in this case the result is going to be a track so let’s again call is result any object and now we won’t check for errors here you should but again for simplicity sake you have seen how to check for errors now in many cases so let’s simply play that track now so let’s say this is it going to be a track we used results convert it to an SPT track and now we can again use our

player so it’s a self-taught player dot a play track provider and this time our track provider is not an album but a single track and we won’t have a callback here so that’s it actually and with this we hopefully will listen to some disney music now so let’s give it a try and there we go there is frozen and I’m going to quit that not that the that this video is going to be deleted from YouTube because of some kinds of rights problems by by playing Disney music so that’s it actually you have now created an application that takes advantage of the Spotify API you have seen how you manage the authentication process of Spotify you have created an Xcode project and that can work with the with the Spotify SDK and you have also created set up the developer environment of Spotify and of course you have also this server running which is pretty important so always keep in mind that if your login process does not work you have to run this server so again what you need to do is call Ruby Spotify token swap dot RB which will run this the server and enable you to to authenticate with the Spotify service and of course if you want to use this in a real application then you would need to you would need to bring this stuff this token exchange server – to a server that can be reached over the Internet so have fun with this with this Spotify SDK example and let me know what you think about this SDK and also if you want to see more tutorials using this the Spotify service