npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-feed-media-audio-player

v4.1.0

Published

This is a React Native bridge for the Feed.fm iOS and Android SDKs

Downloads

375

Readme

react-native-feed-media-audio-player

This library will expose the iOS and Android Feed.fm SDKs for use in React Native projects for music playback.

How to use

From your React Native v0.60 or above project, run:

npm install react-native-feed-media-audio-player
cd ios
pod install

done!

Sample

Check out ExampleUI.js in this package for a minimal native React component that plays music using this library and displays play/pause/skip/volume controls along with the current song.

Usage

At the start of your app, call initialize to create the singleton player instance and have it contact feed.fm and wait for a list of available music stations:

import audioPlayerService from 'react-native-feed-media-audio-player';

audioPlayerService.initialize({ token: 'demo', secret: 'demo', debug: true });

The audioPlayerService exposes the singleton player via audioPlayerService.player.

The player instance has a number of simple playback methods to control playback: play(), pause(), skip(), stop().

The player holds a playbackState that indicates what it is doing. That state is one of:

  • UNINITIALIZED the player is still trying to contact feed.fm
  • UNAVAILABLE the player has no connectivity or feed.fm determined the client isn't allowed to play music at this time
  • WAITING_FOR_ITEM the player is waiting for the next song to play from feed.fm
  • READY_TO_PLAY the player is idle and ready to play music
  • PLAYING the player is actively playing a song
  • PAUSED the player has paused playback of the current song
  • STALLED the player is waiting for more audio data to arrive over the network

The player holds a stations property that is a list of stations that it can pull music from. If the player is playing a song, details of the current song are available via the currentPlay.

The player's activeStation property can be assigned one of the stations from stations.

The player emits events to announce changes in its state. Clients can subscribe to events via player.on(event, callback), which returns a function to unsubscribe from the event. The events (and the objects passed with them to subscribers) are:

  • play-started (play) A new song has started playback
  • state-change (playbackState) The player's state has changed
  • station-change (station) The current station has changed
  • skip-failed The last skip request has failed

The player is of no use until it successfully contacts feed.fm and receives a list of stations that the client can play music from. We say that the player is determining if music is available. To simplify checking whether the player has finished contacting feed.fm and determined if music is available, the player.whenAvailable(callback) method can be used. That method calls the provided function as soon as the player knows whether music is available or not:

player.whenAvailable((available) => {
  if (!available) {
    // no music is available for this client
    return;

  } else {
    // music is available! listen to events..
    player.on('xxx', () => { });

    // pick a station from player.stations:
    player.activeStation = player.stations[indexOfSomeStation];

    // start playback!
    player.play();

  }
});

When the player is not available, there is no music that the user can listen to (due to either lack of Internet connectivity or the user is in a location where playback is not licensed). The player's playback state will be UNAVAILABLE. In that situation, you should not render any music playback controls, as the player is effectively useless.

Otherwise, when the player is available, it will hold an activeStation and a list of available stations, and will respond to playback methods.