Feed.fm Android SDK

Seamlessly integrate music into your Android application and quickly transform your digital experiences using the Feed.fm Android SDK. 
Hero_Feed.fm_SDK

Android Overview

Enhance your Android app with a music player using Feed.fm’s Android SDK.

The SDK is easily accessible through The Central Repository or the GitHub Android SDK Release Page as an {.aar} and supports all recent Android API releases from API 23 upwards.

It relies on Google's ExoPlayer for optimal audio playback across various environments. To accommodate dependency compatibility, Feed.fm offers multiple SDK versions, each aligned with different ExoPlayer versions.

This ensures seamless integration and a smooth user experience regardless of the underlying technology changes.

Advanced Features for Engaging User Experience
Stay updated with the latest features like Android Notifications for lock screen playback control. 

Feed.fm provides a fully functional music player that supports an extensive range of stations and station types, including streaming, on-demand, simulcast, and offline playback.

Feed.fm Android SDK Concepts

The SDK relies on two primary classes: FeedAudioPlayer and FeedPlayerService.

  • FeedAudioPlayer: A comprehensive music player that streams music directly from the Feed.fm servers.
  • FeedPlayerService: An optional class that manages a singleton instance of FeedAudioPlayer. It integrates with Android Foreground Service and Notifications, enabling music to continue while your app runs in the background and allowing control via lock screen and media controls. If your app doesn't need a service, use the FeedAudioPlayer builder instead.

Most FeedAudioPlayer features work asynchronously, so you can implement listener interfaces to receive player event notifications.

 

Initialization and Setup

  1. FeedAudioPlayer needs a token and secret to access the Feed.fm server, confirm the client is in a licensed region, and retrieve a list of available stations.



  2. Add the following to your build.gradle file:
    compile 'fm.feed.android:player-sdk:latest'


  3. Use the following code snippet to initialize FeedAudioPlayer:

    new FeedAudioPlayer.Builder(getApplicationContext(), "demo", "demo").setAvailabilityListener(new AvailabilityListener() {

                @Override
                public void onPlayerAvailable(@NonNull FeedAudioPlayer player) {
                    // player is now ready, save its reference for later use
                    mPlayer = player;
                    // get the station list
                    StationList list = player.getStationList();
                    //set the correct station
                    player.setActiveStation(list.getFirst(),false);
                    //call play
                    player.play();
                }

                @Override
                public void onPlayerUnavailable(@NonNull Exception e) {
                    // Player is not available, the the user does not have a correct location or feed servers could not be reached. 
                    
                }
            }).build();


  4. Enable automatic network retry by setting FeedAudioPlayer.autoNetworkRetry = true

 


FeedPlayerService

Alternatively, create a FeedAudioPlayer singleton using FeedPlayerService:

Enabling Android Foreground Service and Notifications allows your app to continue playing music in the background and enables control of playback from the lock screen and media controls. This feature is particularly useful for apps without their own service that need to continue playing music while running in the background.

FeedPlayerService.initialize(getApplicationContext(), "demo", "demo"); 

Access the player singleton with an availability listener.


FeedPlayerService.getInstance(new AvailabilityListener() {
       @Override
       public void onPlayerAvailable(@NonNull FeedAudioPlayer player) {
           
       }

       @Override
       public void onPlayerUnavailable(@NonNull Exception e) {

       }
   });

 

Testing Credentials

 

  • demo demo: Three simple stations with no skip limits.
  • counting counting: A station with short audio clips counting from 0 to 9, useful for testing transitions.
  • badgeo badgeo: Simulates an unlicensed region response from the server.

 

States

 

State Description
UNINITIALIZED     Player hasn't contacted feed.fm yet
READY_TO_PLAY     Player is ready to begin music playback
PAUSED Music playback has paused
PLAYING Music playback is happening
STALLED The player is waiting for music data from the feed.fm CDN
WAITING_FOR_ITEM The player is waiting for the feed.fm servers to tell is what the next song will be
UNAVAILABLE No music is available for the current client. This is most likely due to the client being outside of the US.

 

Before you begin, familiarize yourself with FeedAudioPlayer states to handle them appropriately.

Android API References

Access our complete Android API reference for the latest version of the Android SDK.

 

Feed.fm Andriod SDK features

Ready to test drive the Android 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!