Adblock Radio client SDK
This is a JS Node & browser library to connect to adblockradio.com API servers. It provides live information about the nature of broadcast contents: either ads, talk or music. It also gives the average volume gain of radio streams so that channel-hopping between stations does not lead to volume variations.
Installation
$ npm install
Usage in browser:
The demo script demo.js
requires libabr.js
. To test it in a browser, you need to use browserify.
$ browserify demo.js -o bundle.js
or
$ npm run build
Then launch a local web server at http://localhost:5000
:
$ serve -s
The demo has no UI, everything happens in the web console (F12 to display it in Firefox & Chrome).
Usage in Node:
Put a valid token in a token
file. Then:
$ nodejs demo_node.js
How to get an API token
A token is required to use this API. To get one:
- register on https://www.adblockradio.com/player with a valid email, if not already done.
- watch your inbox for the confirmation email (it may not arrive immediately).
- the email contains a link to open the Adblock Radio player, of the form https://www.adblockradio.com/player/?t=redactedtokenblahblahcopypasteme&lang=fr
- with the example link above, the token would be "redactedtokenblahblahcopypasteme".
Documentation
The workflow is to call connectServer
, then get the list of available streams with getSupportedRadios
. You create a list of desired radios and send it to the server with sendPlaylist
. You register to a prediction callback with setPredictionCallback
. It will give you live updates about the streams status.
If a prediction is incorrect, use sendFlag
to help improve the system.
If you want to send some feedback with the API, use sendFeedback
.
Demo usage
var abrsdk = ;var token = "change me"; var { if err return console; if !isConnected return console; abrsdk;} var { var status volume; for var i=0; i<predictionsradioslength; i++ // normalized volume to apply to the audio tag to have similar loudness between channels volume = Math; // you can now plug the data to your radio player. console; } abrsdk;
Licence
MIT