Coder Social home page Coder Social logo

ios-sdk's Introduction

Feed Media SDK for iOS Quickstart Guide

Introduction

The Feed Media SDK for iOS allows you to play DMCA compliant radio within your iOS apps. You can read more about the Feed Media API at http://feed.fm/. The primary object you will use to access the Feed Media API is the FMAudioPlayer singleton, which uses AVFoundation for audio playback.

This quickstart guide assumes you will be using a single placement and the static library distribution of the Feed Media SDK, but the full source is available on Github at https://github.com/fuzz-radio/iOS-SDK.

Before you begin, you should have an account at feed.fm and set up at least one placement and station. If you have not already done so, please go to http://feed.fm/.

Definitions

Placement: A placement is a way to identify a location to play music in. It consists of one or more stations to pull music from, and budget rules to limit how much music to serve (on a per user or per placement basis). You may have one or more placements in your app. You can manage your placements at http://feed.fm/.

Station: A station is a collection of music that you select using the dashboard at http://feed.fm/. One station can be assigned to multiple placements.

Client Token and Client Secret: When you create an account at http://feed.fm/, you are issued a unique client token and secret. These keys are used to identify your app to the Feed Media API.

Adding Files

  1. Add the SDK to your project: File --> Add Files to "<Your Project>"...
    1. Chose the "Feed Media SDK" folder in the dialog
    2. For "Destination", check "Copy items into destination group's folder (if needed)"
    3. For "Folders", select "Create groups for any added folders"
    4. For "Add to targets", check all targets where you'll be using the SDK
  2. Link required libraries
    1. Select your project in the Project Navigator
    2. Select your target
    3. Select the "Build Phases" tab
    4. Expand "Link Binary With Libraries"
    5. Click the "+" to add CoreMedia.framework, AVFoundation.framework, and SystemConfiguration.framework

Initializing the SDK

  1. In your Application Delegate's implementation (.m file), add FMAudioPlayer to the list of #imported files

    #import "MyAppDelegate.h" //...// #import "FMAudioPlayer.h"

  2. Set your client token and secret, placementId, and optionally set the log level:

    -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

     FMLogSetLevel(FMLogLevelDebug);
     [FMAudioPlayer setClientToken:@"Your Client Token"
                            secret:@"Your Client Secret"];
     [[FMAudioPlayer sharedPlayer] setPlacement:@"Your Placement ID"];
    
     // Your app specific setup...
     return YES;
    

    }

Playing Music with FMAudioPlayer

  1. In your View Controller's implementation (.m file), add FMAudioPlayer to the list of #imported files:

    #import "MyViewController.h" //...// #import "FMAudioPlayer.h"

  2. Register for notifications to update your UI to display song metadata

    • (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateSongMetadata:) name:FMAudioPlayerCurrentItemDidChangeNotification object:[FMAudioPlayer sharedPlayer]]; // Your view controller's internal setup... }

    -(void)updateSongMetadata:(NSNotification*)notification { // Use the properties of [FMAudioPlayer sharedPlayer].currentItem like name, artist, album, etc... // You can find the available properties in "FMAudioItem.h" }

    // Remember to remove yourself from notifications on dealloc

    • (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; }
  3. Optionally request available stations:

    [[FMAudioPlayer sharedPlayer] requestStationsForPlacement:[FMAudioPlayer sharedPlayer].activePlacementId withSuccess:^(NSArray *stations) { //Present the user with the list of stations to choose from //stations is a list of FMStation objects, which have a name NSString property for display } failure:^(NSError *error) { NSLog(@"Failed to receive stations: %@", error); }];

  4. Optionally set a specific station to play (if this step is omitted, the player will use the active placement's default station):

    FMStation *station = stations[i]; //assume user selected the ith station from a -requestStations call [[FMAudioPlayer sharedPlayer] setStation:station];

  5. Begin playback:

    [[FMAudioPlayer sharedPlayer] play];

Resources

For more information, please contact [email protected] or check out our Github repo at https://github.com/fuzz-radio/iOS-SDK.

ios-sdk's People

Contributors

jamesant avatar yn avatar jeffyasuda avatar matthewmaker avatar

Watchers

John Palgut avatar Ryan Schultz avatar Christopher Grelik avatar James Cloos avatar  avatar Eric McConkie avatar Jose Climaco avatar  avatar Tiffany Wei avatar  avatar Ian Richardson avatar Adam Loo avatar  avatar Todd Fulton avatar Steven Baum avatar  avatar Christophe Wagner avatar Sean Delaney avatar  avatar  avatar Giuseppe Barbalinardo avatar Austine Lee  avatar  avatar  avatar Jayson avatar Philip Lauffenburger avatar Daniel Prato avatar Joshua Cole avatar Jessica(Jiayu) Zeng avatar Yehui Huang avatar  avatar Kevin Wong avatar Richard Blanchard avatar  avatar Irene Li avatar Miguel Campos avatar  avatar Jimmy Song avatar  avatar  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.