Decentralised music based on Hypercore
Decentralised music using the Hypercore protocol.
Built on top of hyperdrive.
npm i dcent-beats
#### const dBeats = new DcentBeats(drive, location)
Create a new Dcent Beats instance.
drive is a Hyperdrive instance, and location the folder where the music lives.
#### const key = dBeats.key
Returns the key corresponding to the underlying hyperdrive.
#### const blobsKey = dBeats.blobsKey
Returns the key corresponding to the underlying hyperdrive's blobs hypercore.
#### const dBeats = await dBeats.put(blob)
Upload a song. blob should contain the raw bytes of an mp3 file.
#### const dBeats = await dBeats.exists()
Returns true if a song exists at the location of this dcent beats instance, false otherwise.
#### const blob = await dBeats.get()
Get the audio as a blob of bytes.
#### const stream = dBeats.createReadStream()
Returns the audio stream of the song.
#### const metadata = await dBeats.getMetadata()
Get the metadata corresponding to this Dcent Beats song.
The metadata is an object:
```
{
year, // Year of publishing
title, // Song title
artist, // Song artist
durationSec, // Song duration in seconds
version // internal version info ({ major, minor })
}
#### const cover = await dBeats.getCover()
Return the song's cover image (null otherwise).
cover is an object:
``
{
data, // The raw data of the image (bytes)
format, // The image format, as used in an html tag (e.g. 'image/jpeg')
major, // int: the major version of this cover structure
minor / int: the minor version of this cover structure
}
#### await dBeats.close()
Close the dcent beats instance, cleaning up its hyperdrive session.
#### await dBeats.ready()`
Open the dcent beats instance, ensuring its hyperdrive session is opened.