From 1e36c9e02c30565a850d8b26d60de859a2ac0ab8 Mon Sep 17 00:00:00 2001 From: Zane V Date: Sun, 10 May 2026 15:26:31 +0000 Subject: [PATCH] Upload tbd --- LocalRadioPlayer.js | 61 +++++++++++++++++++++++++++++++++++++++++++++ index.js | 11 ++++++++ package.json | 20 +++++++++++++++ release_notes.json | 4 +++ 4 files changed, 96 insertions(+) create mode 100644 LocalRadioPlayer.js create mode 100644 index.js create mode 100644 package.json create mode 100644 release_notes.json diff --git a/LocalRadioPlayer.js b/LocalRadioPlayer.js new file mode 100644 index 0000000..a4fffd0 --- /dev/null +++ b/LocalRadioPlayer.js @@ -0,0 +1,61 @@ +const EventEmitter = require('events'); + +class LocalRadioPlayer extends EventEmitter { + constructor() { + super(); + this._stations = { + 'Rock': 'http://localhost:8000/rock', + 'Pop': 'http://localhost:8000/pop', + 'Jazz': 'http://localhost:8000/jazz', + 'Classical': 'http://localhost:8000/classical', + 'Electronic': 'http://localhost:8000/electronic', + 'Hip-Hop': 'http://localhost:8000/hiphop' + }; + this._audio = null; + } + + getStations(options) { + return Promise.resolve(Object.keys(this._stations).map(genre => ({ + name: genre, + id: genre + }))); + } + + play(stationData) { + if (this._audio) { + this._audio.pause(); + } + const streamUrl = this._stations[stationData.id]; + if (!streamUrl) { + this.emit('error', new Error(`Station ${stationData.id} not found.`)); + return; + } + + this._audio = new Audio(streamUrl); + this._audio.play() + .then(() => { + this.emit('song-data', { + title: `Streaming ${stationData.id}`, + artist: 'Local Radio', + albumArt: '' + }); + }) + .catch(err => { + this.emit('error', err); + }); + } + + stop() { + if (this._audio) { + this._audio.pause(); + this._audio = null; + } + } + + resizeArtwork(options) { + // Not applicable for local streaming without metadata + return Promise.resolve(''); + } +} + +module.exports = LocalRadioPlayer; diff --git a/index.js b/index.js new file mode 100644 index 0000000..cc2301a --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +const LocalRadioPlayer = require('./LocalRadioPlayer'); + +/** + * @returns {RadioPlayer} + * + * i tried to make the radio work as well, coldnt get it to work :( + */ +module.exports = function createRadio() { + return new LocalRadioPlayer(); +}; + diff --git a/package.json b/package.json new file mode 100644 index 0000000..1db6d92 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "jibo-tbd", + "version": "3.3.0 InDev", + "description": "Jibo full-stack release version", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git@github.jibo.com:rm/jibo-version.git" + }, + "keywords": [ + "full-stack", + "release", + "version" + ], + "author": "JiboRevivalGroup", + "license": "ISC" +} diff --git a/release_notes.json b/release_notes.json new file mode 100644 index 0000000..5021743 --- /dev/null +++ b/release_notes.json @@ -0,0 +1,4 @@ +{ + "spoken": "Last dance. Last chance, for love.", + "enableProactive": true +}