diff --git a/appinfo/info.xml b/appinfo/info.xml index 8f46e48..0c3dd72 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -16,6 +16,9 @@ + + OCA\Radio\Command\Search + Radio diff --git a/src/components/Main.vue b/src/components/Main.vue index 2f4bb14..8d0cd62 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -6,7 +6,9 @@ - +
@@ -20,6 +22,8 @@ import Navigation from './Navigation' import Table from './Table' import { Howl } from 'howler' +let audioPlayer = null + export default { name: 'Main', components: { @@ -37,26 +41,31 @@ export default { mounted() { this.loadStations() this.scroll() - this.play() }, methods: { - play() { - const sound = new Howl({ - src: ['http://stream.srg-ssr.ch/m/drsvirus/mp3_128'], + doPlay(station) { + if (audioPlayer !== null) { + audioPlayer.fade(100, 0, 500) // FIXME persistent volume state + audioPlayer.unload() // FIXME do unload after fadeout + } + audioPlayer = new Howl({ + src: [station.url_resolved], + volume: 0, }) - sound.play() + audioPlayer.play() + audioPlayer.fade(0, 100, 500) // FIXME persistent volume state }, loadStations() { const vm = this - this.$jquery.ajax({ - type: 'POST', - url: 'https://de1.api.radio-browser.info/json/stations/topclick', - data: '{ "limit": 20, "offset": 20 }', - contentType: 'application/json', - dataType: 'json', - }) + this.$jquery.getJSON('https://de1.api.radio-browser.info/json/stations/search', + { + limit: 20, + order: 'clickcount', + reverse: true, + offset: vm.offset, + 'User-Agent': 'Nextcloud Radio/1.0.0', // FIXME global version + }) .done(function(data) { - console.log('new data') vm.tableData = vm.tableData.concat(data) vm.offset += 20 }) diff --git a/src/components/Table.vue b/src/components/Table.vue index 525e14b..e7a702f 100644 --- a/src/components/Table.vue +++ b/src/components/Table.vue @@ -11,11 +11,11 @@ - -
+
+ {{ station.name }} @@ -51,6 +51,11 @@ export default { default() { return [] }, }, }, + methods: { + doPlay(station) { + this.$emit('doPlay', station) + }, + }, } @@ -110,6 +115,11 @@ table { td.filenameColumn .innernametext { color: var(--color-main-text); + text-overflow: ellipsis; + overflow: hidden; + position: relative; + vertical-align: top; + user-select: none; } .stationIcon { diff --git a/src/main.js b/src/main.js index 4d1aa2a..bdd57c6 100644 --- a/src/main.js +++ b/src/main.js @@ -35,5 +35,10 @@ Vue.prototype.$jquery = jquery export default new Vue({ el: '#content', router, + methods: { + doPlay() { + console.log('event handled!') + }, + }, render: h => h(App), })