Socket
Socket
Sign inDemoInstall

pear-radio-backend

Package Overview
Dependencies
87
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pear-radio-backend

Pear radio backend


Version published
Weekly downloads
73
increased by7200%
Maintainers
0
Created
Weekly downloads
 

Readme

Source

Pear Radio Backend

Backend connectivity for Pear Radio.

API

User

User communication interface.

const user = new User(syncResponseCallback, opts)
await user.ready()
await user.getUserInfo(key)

Gets user/streamer information by key.

const info = await user.getUserInfo(key)

User information is an object:

{
  publicKey: buffer,
  name: string,
  description: string,
  tags: c.string
}
await user.syncRequest(key)

Gets user/streamer information about the track that is streaming at the moment.

const info = await user.syncRequest(key)
{
  block: uint,
  artist: string,
  name: string
}

Listener

Receives stream from remote user/streamer.

const listener = new Listener(userPublicKey, swarm, store)
await listener.ready()
await listener.listen(fromBlock)

Returns the stream of the remote user core, starting from block fromBlock. Each block corresponds to ~1 second of audio.

Streamer

Streams audio data and metadata.

const streamer = new Streamer(keyPair, swarm, store, opts)
await streamer.ready()
await streamer.stream(metadata, stream, opts)

Streams single track.

Mp3ReadStream

Collection of static methods to read mp3 files and ID3 tags.

Mp3ReadStream.stream(path)

Returns { localStream, remoteStream }. localStream is a fs.createReadStream of a given file. remoteStream streams chunks of the file of ~1 second of audio.

Mp3ReadStream.readTrack(path)

Return metadata and duration information of an mp3 file.

{
  file: string // filename
  name: string, // track title
  artist: string, // track artist
  duration: uint, // duration in seconds
  path: string // absolute path of the file
}

HttpAudioStreamer

Http server that stream mp3 files for local consumption.

const httpStreamer = new HttpAudioStreamer()
const port = await httpStreamer.ready()
httpStreamer.stream(stream)
const { localStream } = Mp3ReadStream.stream(absPath)
httpStreamer.stream(localStream) // stream mp3 file in localhost:$port

PearRadioConfiguration

Hyperbee that stores pear radio user information.

const configuration = new PearRadioConfiguration()
await configuration.ready()
configuration.get(key)

Returns value of the given key.

configuration.set(key, value)

Sets value for the given key, with format compact-encoding.any.

TagManager

Hyperswarm based tags search for users connectivity.

const tagManager = new TagManager(user)
await tagManager.ready()

The tagManager will announce itself in the #all topic, and store all connections in the tagManager.tags.

tagManager.announce(tag)

Announces tag manager in the given tag topic.

tagManager.searchByTag(tag)
await tagManager.searchByTag(tag)
tagManager.on('stream-found', (userInfo) => {
  console.log(userInfo)
})

FAQs

Last updated on 24 Jun 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc