Feed.fm iOS SDK

Seamlessly integrate music into your iOS or tvOS application and quickly transform your digital experiences using the Feed.fm iOS SDK. 
music api for businesses feed.fm code on laptop and mobile app music player examples

iOS Overview

Feed.fm's iOS SDK is your gateway to enriching your app with robust audio functionalities, easily accessible through CocoaPods or Swift Package Manager.

Flexible Installation Options
From Xcode 12 onwards, adding Feed Media to your project is straightforward:

  1. Select File > Swift Packages > Add Package Dependency.
  2. Enter this GitHub URL: https://github.com/feedfm/iOS-SDK in the "Choose Package Repository" dialog.
  3. For the version, choose "Up to Next Major" and set "5.5.0" as the earliest version.
  4. After Xcode processes the source, simply select the "FeedMedia" library and integrate it directly into your app target.

Rich Features and Tools
Our SDK is regularly updated with the latest features, including:

  • Lock Screen Integration: Manage background playback directly from the iOS lock screen.
  • MarqueeLabel Library: Create a marquee effect for long UILabels that display song metadata, enhancing UI dynamics.
  • Sample Music Player: Supports any number of stations and station types, including streaming, on-demand, simulcast, and offline playback.

 

Using swift? Check out our public demo written in swift.

Getting started with the Feed.fm iOS SDK

The SDK revolves around a singleton instance of the FMAudioPlayer class, which offers straightforward methods to control music playback, such as play, pause, and skip.

The FMAudioPlayer maintains a list of FMStation objects (stationList), one of which is always designated as the active station (activeStation). Once music playback has started, there is a current song (currentSong).

 

Typical Initialization and Setup:

To initialize the SDK, you should call:

[FMAudioPlayer setClientToken:@"demo" secret:@"demo"]

This call should be made as early as possible in your app’s lifecycle, preferably in the AppDelegate or initial ViewController. This asynchronous call contacts the Feed.fm servers, confirms that the client is in a region where music can legally be played, and retrieves a list of available music stations.

 

Sample Credentials for Testing:

Here are some sample credentials you can use to test your app:

  • 'demo, demo': Provides access to three simple stations with no skip limits.
  • 'badgeo, badgeo': Simulates the response when accessing from outside the U.S.
  • 'counting, counting': Plays short audio clips of a voice saying the numbers 0 through 9.

 

Handling Music Availability:

To receive notifications about music availability, use the whenAvailable:notAvailable: method. This method will call only one of its arguments, based on whether or not music is available:

FMAudioPlayer *player = [FMAudioPlayer sharedPlayer];

[player whenAvailable:^{
  NSLog(@"music is available!");
  // .. do something, now that you know music is available

  // set player settings
  player.crossfadeInEnabled = true;
  player.secondsOfCrossfade = 4;
  [player play];

 } notAvailable: ^{
    NSLog(@"music is not available!");
    // .. do something, like leave music button hidden

 }];
 // Set Notifications for ex to listen for player events
 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stateDidChange:) name:FMAudioPlayerPlaybackStateDidChangeNotification object:[FMAudioPlayer sharedPlayer]];

iOS SDK UI Elements

The iOS SDK includes UI elements such as play/pause, skip, and like/dislike buttons that you can use directly by setting the class.

A full list of all the available classes can be found on our GitHub repository.

 

Feed.fm iOS SDK details including media player features, playback functionality and OTT capabilities.

Ready to test drive the iOS SDK?

Talk to a music specialist to get your token today

Hop on a quick call to get token access and test Feed.fm's cutting-edge music player SDKs. Unlock the power of seamless integration and take your app to the next level. Let's innovate together!