diff --git a/src/httpd_streaming.c b/src/httpd_streaming.c index 52b6bfdb..547b624d 100644 --- a/src/httpd_streaming.c +++ b/src/httpd_streaming.c @@ -46,8 +46,6 @@ extern struct event_base *evbase_httpd; #define STREAMING_SILENCE_INTERVAL 1 // Buffer size for transmitting from player to httpd thread #define STREAMING_RAWBUF_SIZE (STOB(AIRTUNES_V2_PACKET_SAMPLES)) -// Should prevent that we keep transcoding to dead connections -#define STREAMING_CONNECTION_TIMEOUT 60 // Linked list of mp3 streaming requests struct streaming_session { @@ -74,6 +72,7 @@ static struct player_status streaming_player_status; static int streaming_player_changed; static int streaming_pipe[2]; + static void streaming_fail_cb(struct evhttp_connection *evcon, void *arg) { @@ -243,6 +242,8 @@ streaming_request(struct evhttp_request *req, struct httpd_uri_parsed *uri_parse evhttp_add_header(output_headers, "Pragma", "no-cache"); evhttp_add_header(output_headers, "Expires", "Mon, 31 Aug 2015 06:00:00 GMT"); evhttp_add_header(output_headers, "icy-name", name); + evhttp_add_header(output_headers, "Access-Control-Allow-Origin", "*"); + evhttp_add_header(output_headers, "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); // TODO ICY metaint evhttp_send_reply_start(req, HTTP_OK, "OK"); @@ -263,7 +264,6 @@ streaming_request(struct evhttp_request *req, struct httpd_uri_parsed *uri_parse session->next = streaming_sessions; streaming_sessions = session; - evhttp_connection_set_timeout(evcon, STREAMING_CONNECTION_TIMEOUT); evhttp_connection_set_closecb(evcon, streaming_fail_cb, session); return 0; diff --git a/web-src/src/audio.js b/web-src/src/audio.js new file mode 100644 index 00000000..2d9d7995 --- /dev/null +++ b/web-src/src/audio.js @@ -0,0 +1,54 @@ +/** + * Audio handler object + * Taken from https://github.com/rainner/soma-fm-player (released under MIT licence) + */ +export default { + _audio: new Audio(), + _context: new AudioContext(), + _source: null, + _gain: null, + + // setup audio routing + setupAudio () { + this._source = this._context.createMediaElementSource(this._audio) + this._gain = this._context.createGain() + + this._source.connect(this._gain) + this._gain.connect(this._context.destination) + + this._audio.addEventListener('canplaythrough', e => { + this._audio.play() + }) + this._audio.addEventListener('canplay', e => { + this._audio.play() + }) + return this._audio + }, + + // set audio volume + setVolume (volume) { + if (!this._gain) return + volume = parseFloat(volume) || 0.0 + volume = (volume < 0) ? 0 : volume + volume = (volume > 1) ? 1 : volume + this._gain.gain.value = volume + }, + + // play audio source url + playSource (source) { + this.stopAudio() + this._context.resume().then(() => { + console.log('playSource') + this._audio.src = String(source || '') + '?x=' + Date.now() + this._audio.crossOrigin = 'anonymous' + this._audio.load() + }) + }, + + // stop playing audio + stopAudio () { + try { this._audio.pause() } catch (e) {} + try { this._audio.stop() } catch (e) {} + try { this._audio.close() } catch (e) {} + } +} diff --git a/web-src/src/components/ModalDialogQueueItem.vue b/web-src/src/components/ModalDialogQueueItem.vue index 7f708f5c..c960adeb 100644 --- a/web-src/src/components/ModalDialogQueueItem.vue +++ b/web-src/src/components/ModalDialogQueueItem.vue @@ -98,7 +98,7 @@ export default { }, open_genre: function () { - this.$router.push({ path: '/music/genres/' + this.item.genre }) + this.$router.push({ name: 'Genre', params: { genre: this.item.name } }) } } } diff --git a/web-src/src/components/ModalDialogTrack.vue b/web-src/src/components/ModalDialogTrack.vue index 73db078d..69628595 100644 --- a/web-src/src/components/ModalDialogTrack.vue +++ b/web-src/src/components/ModalDialogTrack.vue @@ -37,9 +37,9 @@ Year {{ track.year }}

-

+

Genre - {{ track.genre }} + {{ track.genre }}

Track / Disc @@ -55,7 +55,7 @@

Type - {{ track.media_kind }} - {{ track.data_kind }} + {{ track.media_kind }} - {{ track.data_kind }} (artist, album)

Added at @@ -88,6 +88,7 @@ diff --git a/web-src/src/components/NavBarItemOutput.vue b/web-src/src/components/NavBarItemOutput.vue index 881ec6c8..53d67957 100644 --- a/web-src/src/components/NavBarItemOutput.vue +++ b/web-src/src/components/NavBarItemOutput.vue @@ -3,7 +3,7 @@

- +
diff --git a/web-src/src/components/NavbarTop.vue b/web-src/src/components/NavbarTop.vue index 84c5802b..d7fdda10 100644 --- a/web-src/src/components/NavbarTop.vue +++ b/web-src/src/components/NavbarTop.vue @@ -39,7 +39,9 @@
- + + +
@@ -60,6 +62,31 @@ + + +