Code Monkey home page Code Monkey logo

spotifydemo's Introduction

Spotify Demo

Spotify player with albums in a collection view, and a login screen. Written in Swift3, using Spotify iOS SDK (beta).

Updates

The 'continue without logging in' is not yet accounted for. The player will not work because calls cannot be made to Spotify API without a session token. Logging in with a non-Premium account is also in progress (this will play a 30 second sample instead of trying to stream).

Requirements (Tested)

  • Swift 3
  • XCode 8.3.3
  • CocoaPods 4.x.x

Frameworks and Dependencies

  • SpotifyAudioPlayback, SpotifyAuthentication, SpotifyMetaData
  • PromiseKit

How to run this project

  1. Install pod dependencies.
$ pod install
  1. Open the workspace project.
  2. Run simulator to see demo.

How to integrate this project into another project

We will break this up into three parts: (1) Downloading the SDK and importing frameworks; (2) Creating an account in Spotify Developer to get credentials and callback URL; and (3) Updating your XCode project's project settings. For more information, visit Spotify Developer Site

1. Download SDK and import frameworks: this should already be included in SpotifyDemo, so you can skip this step. If you still want to do it yourself:

  • Checkout master branch from Github Spotify iOS SDK.
  • Copy frameworks into a SpotifyFrameworks folder.
  • Create an ObjectiveC bridging header to import frameworks.

Install PromiseKit:

  • If you don't have a podfile, run:
$ pod init
  • If you have a pod file, make sure that under your project target, include pod "PromiseKit", "~> 4.0"
  • Install.
$ pod install

2. Create account in Spotify Developer: Currently this project has credentials from an existing account (you shouldn't actually do this), so you have to create your own account.

  • Go to https://developer.spotify.com/

  • Go to My Apps, at the navigation bar.

  • Login to your Spotify account (don't worry, this is still free as of 07/14/2017).

  • Go to My Applications and CREATE AN APP

  • Fill in the following:

    Application Name: name of your application
    Description: Describe it.
    Redirect URIs: This can be anything, really. Follow format unique-prefix://callback. We're using this for the login function, so you can call it something like login://returnAfterLogin.
    Bundle ID: This is the ID for your project, of the form com.company.ProjectName

    Make note of the client ID and secret, this will be used later.

  • Save.

3. Update XCode project

  • In Build Settings -> Other Linker flags -> add -ObjC and $(inherited)
  • In Build Phases -> Link binary with libraries: SpotifyMetadata.framework, SpotifyAudioPlayback.framework, SpotifyAuthentication.framework
  • In Info -> Add URL type:
    • Identifier: bundle identifier+identifier (com.company.ProjectName.spotify-auth)
    • URL scheme: first section of callback URL (if your callback was spotify-test-login://callback, then url scheme is spotify-test-login).

After this you can copy the files: SpotifyManager.swift, SpotifyViewController.swift, SpotifyLoginViewController.swift, PlaylistCollectionViewCell.swift, Main.storybord, SpotifyDemo-Bridging-Header.h (if you didn't make this...may need to update the path in Project settings)

Update the client id and secret in SpotifyManager.swift.

Classes

  1. SpotifyManager: NSObject, SPTAudioStreamingPlaybackDelegate, SPTAudioStreamingDelegate
    Singleton that manages Spotify login and streaming, playback.

  2. SpotifyViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource
    The ViewController that contains the playlist. Has a collection view that displays clickable albums.

  3. SpotifyLoginViewController: UIViewController
    Login page, segues to SpotifyViewController.

  4. PlaylistCollectionViewCell: UICollectionViewCell
    Custom cell for the collection view used in SpotifyViewController.

spotifydemo's People

Watchers

James Cloos avatar Rena Chen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.