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

com.feedfm.unity-sdk

v1.0.2

Published

The unity sdk for https://www.feed.fm

Downloads

3

Readme

FeedFM Unity SDK

openupm

Install


Install via OpenUPM

The package is available on the openupm registry. It's recommended to install it via openupm-cli.

openupm add com.feedfm.unity-sdk

Install via Package Manager

  • open Edit/Project Settings/Package Manager
  • add a new Scoped Registry (or edit the existing OpenUPM entry)
  • click Save (or Apply)
  • open Window/Package Manager
  • click +
  • select Add package by name... or Add package from git URL...
  • paste com.feedfm.unity-sdk into name
  • paste 0.0.1 into version
  • click Add

Alternatively, merge the snippet to Packages/manifest.json

{
    "scopedRegistries": [
        {
            "name": "package.openupm.com",
            "url": "https://package.openupm.com",
            "scopes": [
                "com.feedfm.unity-sdk"
            ]
        }
    ],
    "dependencies": {
        "com.feedfm.unity-sdk": "0.0.1"
    }
}

Getting started


To begin playing the music, create a new GameObject and attach the FeedPlayer.cs script to it. Then configure the player by setting token and secret and optional values like crossfade duration etc in the unity editor or by editing the script.

Example Usage

The included "Dancing Robot" demo shows an example on how to interact with FeedPlayer.cs. MusicPlayerView.cs manages the entire UI for the demo subscribing to and calling methods on a FeedPlayer object.

Playing music

[SerializeField] FeedPlayer _feedPlayer = null;

private void Awake()
{
    _feedPlayer.OnSession += (available, errMessage) =>
    {
   
        if (available)
        {
            _feedPlayer.Play();
        }
        else
        {
            Debug.Log(errMessage);
        }
    };

    // Optional events...
}

Optional Events to Subscribe to

    
_feedPlayer.OnStationChanged += station =>
{
    Debug.Log(string.Format("New station {0} is set", station.Name));
};

_feedPlayer.OnPlayStarted += play =>
{
    Debug.Log("play started "+play.AudioFile.TrackTitle);
};

_feedPlayer.OnPlayReadyForPlayback += play =>
{
    Debug.Log(string.Format("play ready for playback {0}", play.AudioFile.TrackTitle));
};

_feedPlayer.OnStateChanged += state =>
{
    Debug.Log(string.Format("State Changed to {0}", state));
};

_feedPlayer.OnProgressUpdate += (play, progress, duration) =>
{
    Debug.Log(string.Format("{0}progress changed to {1} duration {2}", play.AudioFile.TrackTitle, progress, duration));
};
  

FeedPlayer.cs is responsible for retrieving music from the Feed.fm servers and playing them on the local device. The player can be assigned an active station from list of stations returned by the server.

To make sure the music begins when requested user should wait for OnPlayReadyForPlayback event before calling play().

Player methods are almost all asynchronous. Thus, the API is event based. Subscribe to the FeedPlayer.cs events to be notified of changes in the player state.

The player must successfully contact the Feed.fm servers to retrieve a list of available streaming stations and the OnSession helps with determining when music becomes available or playback.

To use this class, add the FeedPlayer to a GameObject in the scene. All dependencies will be handled automatically. You just need to make sure to set the 'token' and 'secret' values to what you were given on feed.fm.

FeedPlayer states.

  • Uninitialized: This is the initial default state, the player is not ready to play music until it transitions out of this state.
  • Unavailable: There is no music available for this user.
  • ReadyToPlay: The player is ready to play music.
  • Stalled: The song is being pulled down.
  • Playing / Paused: We have a song that we've begun playback of and we're either currently playing the song or the song is paused.
  • WaitingForItem: The Player is waiting for feed.fm servers so return a song.
  • Exhausted: The server has run out of music in the current station that passes DMCA playback rules. The station must be changed, to request more music.

The player has following events that can be subscribed to

StationDelegate OnStationChanged   // A new station was set
SessionDelegate OnSession          // A session is not available or unavailable. 
StateHandler OnStateChanged        // Player state has changed. 
PlayHandler OnPlayReadyForPlayback // An Item is loaded and ready for playback. 
PlayHandler OnPlayStarted          // A song has started plaback
PlayHandler OnPlayCompleted        // A song has completed playback. 
ProgressHandler OnProgressUpdate   // A event sent out every second to update the progress of the currently playing song. 

FeedPlayer public API.

Properties

  • ActiveStation { get; set; }
  • CrossFadeDuration { get; set; }

Methods

  • Play()
  • Pause()
  • Skip()
  • State get()
  • StationList get()