Git Product home page Git Product logo

tiny-radio's Introduction

Tiny radio

This is a tiny library that spins up a process playing the provided radio url and exposes a REST-based interface for pausing, playing and controlling volume.

I'm running this on a Raspberry Pi (Ubuntu) connected via USB to my stereo. I interact with the REST API through Home Assistant in various ways.

Example

Spinning up P6 Beat.

node index.js --url="http://live-icy.gss.dr.dk/A/A29H.mp3" --playOnStart

Options

--playOnStart: false by default.

--port: defaults to 3000.

--volumeIncrements: defaults to 5.

--initialVolume: defaults to 50.

REST API

POST /start: starts the radio process. Returns current state.

POST /stop: stops the radio process. Returns current state.

POST /toggle: starts or stops the radio process. Returns current state.

GET /state: returns current state.

POST /volume/up: increases volume by 5 or provided --volumeIncrements. Returns current state.

POST /volume/down: decreases volume by 5 or provided --volumeIncrements. Returns current state.

POST /volume/:volume: sets the volume to whatever provided ie. /volume/10. Returns current state.

State

Every POST call returns the current state which is an object containing these fields:

currentlyPlaying: string. The stream title returned by streaming the url.

volume: int. Current volume.

playing: boolean. Whether or not the radio is currently playing.

Controlling volume

To control volume you'll need to provide an audio sink and have pactl installed on your hots system:

 --audioSink="alsa_output.usb-D___M_Holdings_Inc._PMA-50-00.analog-stereo"

Find your audio-sink by running pactl list. This entire approach could very likely be handled better and more widely supported, but I've just focused on Ubuntu for now. Take a look at the source if you want to see some really hacky stuff. Sorry.

tiny-radio's People

Contributors

ostrgard avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.