diff --git a/appinfo/routes.php b/appinfo/routes.php index 2ee2191..d6f1963 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -37,6 +37,8 @@ return [ // Settings ['name' => 'settings#set_menu_state', 'url' => '/settings/menuState', 'verb' => 'POST'], ['name' => 'settings#get_menu_state', 'url' => '/settings/menuState', 'verb' => 'GET'], + ['name' => 'settings#set_volume_state', 'url' => '/settings/volumeState', 'verb' => 'POST'], + ['name' => 'settings#get_volume_state', 'url' => '/settings/volumeState', 'verb' => 'GET'], // Api ['name' => 'radio_api#preflighted_cors', 'url' => '/api/0.1/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']] diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 036c597..3383c2f 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -99,4 +99,30 @@ class SettingsController extends ApiController { return $this->getSetting('menuState', 'menuState', 'TOP'); } + /** + * set player volume + * + * @param string $playerVolume + * @return JSONResponse + * + * @NoAdminRequired + */ + public function setVolumeState($volumeState = "0.5"): JSONResponse { + return $this->setSetting( + 'volumeState', + $volumeState + ); + } + + /** + * get player volume + * + * @return JSONResponse + * + * @NoAdminRequired + */ + public function getVolumeState(): JSONResponse { + return $this->getSetting('volumeState', 'volumeState', 0.5); + } + } diff --git a/src/assets/blurHashes.json b/src/assets/blurHashes.json new file mode 100644 index 0000000..828d3ca --- /dev/null +++ b/src/assets/blurHashes.json @@ -0,0 +1 @@ +{"963ccae5-0601-11e8-ae97-52543be04c81": "UaEXfHt60SRooffQazfQ0Sod-kWWWYj@j@az","9631dea0-0601-11e8-ae97-52543be04c81": "UKSV.?}p?l~M~Poek9ovxWk9M*Vx}.oKjHs-","9bd15fc0-c84a-11e8-a54a-52543be04c81": "UnD}rAo1WpsUsUa|fQjt2Ea|o1WpN]jtfQa|","e2359b1f-668c-11ea-be63-52543be04c81": "UINi?,n5*hcX_kpGG?Zj5unl#RkpIKRVo{o_","d9fc29b8-b152-11e8-afe1-52543be04c81": "UYPpK81b7eB9_%JRKONa63%2xGsU?vM{RPRj","0ab6a1f5-c47f-4280-b9d7-cbcf4d4be51d": "UYPpK81b7eB9_%JRKONa63%2xGsU?vM{RPRj","965000d4-0601-11e8-ae97-52543be04c81": "UZI#.Uof4nRjWVj[j[ay00j[IUWBRjayt6of","9605edb3-0601-11e8-ae97-52543be04c81": "UXNBe+5M%MSuofayfij[-:bXIVnnoyfif8WV","962af6d2-0601-11e8-ae97-52543be04c81": "UA9?%bkV0fwwKNo1wfSNE2bFWBWB#RayJSn%","e5672382-668a-11ea-be63-52543be04c81": "URHd1[oy0$R-=dX8wIsTHta#yAs:xVaxKjof","961fdb40-0601-11e8-ae97-52543be04c81": "UyQS_6o#%0R-t6ofj[ay~penNJs,NHRjWBoL","aa555e8a-08d9-11e8-ae97-52543be04c81": "U46Hif0n~35F9H$|NM-mE1ocR-s,E3${E5-R","9617a958-0601-11e8-ae97-52543be04c81": "UbHT87V[9vxZs.baoeRk0#fkkVj[RkjZWVs.","96059353-0601-11e8-ae97-52543be04c81": "UKQ4KQniMJt7s:fQaefQHXkCyXaKnOf6kWfk","963de807-0601-11e8-ae97-52543be04c81": "UaEXfHt60SRooffQazfQ0Sod-kWWWYj@j@az","291ced6f-668b-11ea-be63-52543be04c81": "UxOz0-oL.8fQxut7V@RP_NWBMxofRjoLj[oz","9622cd46-0601-11e8-ae97-52543be04c81": "USSiQ:S#%gs:bbbHjFay?^s9MxW;xFjZX9kC","08debba2-bf7e-11e9-8502-52543be04c81": "UXHA0Aj[IAjZt7ayRjj[0yaytRfkV@j[t7ay","6a1440b2-e6f0-11e9-a96c-52543be04c81": "UJGt~@D~y5SaH{W,kRNFtw%3n-ah~qD%IURi","1cfb151d-a341-11e9-a787-52543be04c81": "UpNc@^9hN5Ia~MM}IrNHkFt5R*odRlWBocWB","962cc6df-0601-11e8-ae97-52543be04c81": "UL02sJf,doe.ewf5gJfSe6e-g5f-f1fkemf8","960cf833-0601-11e8-ae97-52543be04c81": "UR8?G^L.pEeX8yoel5Vc.QaMaMjaIBoxbakT","51895bd4-f369-11e8-a471-52543be04c81": "U~KyAQj[fQj[j[fQfQfQ~Wj[fQj[offQfQfQ","9606f727-0601-11e8-ae97-52543be04c81": "UlE.08rYJ6FYofbHbafk0Ko}xHwgRjaeaeay","9aebbdea-d291-11e9-a861-52543be04c81": "UZI$CaNKWEt5RSM$xrM~4bIYWXafM~WC%Ia{","c1d8bcf1-c763-11e8-a54a-52543be04c81": "UaQlk8NaxuaeV@ayj[oz?^nikWtRozofozWB","96062a7b-0601-11e8-ae97-52543be04c81": "UnK1%fj[4nj[WBfQj[j[00ayRjayj[j[j[ay","962e5ddc-0601-11e8-ae97-52543be04c81": "UlQZHYozVZjFofaeaeaeHXaeozkCjFkCkWkB","cb7e0d64-3bc1-4f3d-8510-c4ec611aac7b": "UYN$}_wd9ts:wxjta|fQ8wbHpIV@sUf7fQay","6af0444f-22b9-11ea-aa0c-52543be04c81": "UiQmYIab^9sHbbbak9jG~EoiEdW*smi{WEbt","9636f71a-0601-11e8-ae97-52543be04c81": "UaTOXmozdCnOoffQf6fQdVf+g$e.n$fkfkf6","0718de10-7be1-4e55-a057-c2525a512c42": "UkDlvnWBxroe%MayoffQ4mofM{ay9YoeRjay","9606c2cd-0601-11e8-ae97-52543be04c81": "UkQ$Lyo}Q-jZofkCaef6L#V@pIj[jFaekWj[","9653bbbe-c3a2-11e8-aaf2-52543be04c81": "UZRW6safxut7%2afjtkB~pfkM|afM|ofayae","442bb2bf-0a35-11e8-ae97-52543be04c81": "UsQG%jofZ$sA}Fj[Vse.F_aepIkCrDe.kqkC","961e5274-0601-11e8-ae97-52543be04c81": "UhQk_,KUp0X7XotT$x%0-;R.a~s.oeR.f5oI","96102c22-0601-11e8-ae97-52543be04c81": "UmJ**dj[?bfk~pay-;j[D%WBRjj[kCj[RjkC","960cee1f-0601-11e8-ae97-52543be04c81": "UZF[#Pt70vNZoffQayfQ0wj[-XayW-j[j[ay","96156a3e-0601-11e8-ae97-52543be04c81": "UH0dwAkYaIf,Zxe-f-f4aIe,f,f7k[kEaJf,","961a5858-0601-11e8-ae97-52543be04c81": "UH0dwAkYaIf,Zxe-f-f4aIe,f,f7k[kEaJf,","960b9e98-0601-11e8-ae97-52543be04c81": "URR._k8_kqtR.R.8oeVr4UIUtRt7xuo1RPRj","273c4a22-5a4a-11e8-b0ce-52543be04c81": "USTECp]:gh^k@un%eUnOiIf6icen_Nofi_oz","9606ca07-0601-11e8-ae97-52543be04c81": "UXRTAsm6Mx%1rqa0pIozVYo}f6aKxao~Q,kW","98c77c3a-1291-43a5-980a-ebbc189f73f8": "UXRTAsm6Mx%1rqa0pIozVYo}f6aKxao~Q,kW","960553a5-0601-11e8-ae97-52543be04c81": "UKAmF}x^Nxa0s:fkfQay0fMxw]kXNGe.ayof","961ac56b-0601-11e8-ae97-52543be04c81": "UISgRujYU[ozn~aJkYkDkDkCadf5oJkXkWaK","9616342d-0601-11e8-ae97-52543be04c81": "UXPi|?of4ToL_3ju?bofRjay%gj[8{ayt7jt","3d803a38-d4f1-11e9-a861-52543be04c81": "ULB^I|N_1tsANwsno2WW1sS2=2son~jtWpWq","96104f13-0601-11e8-ae97-52543be04c81": "UGS?7Fo}o}nit7f6j[j[_Ni_VskWWBf+WBWB","9605739a-0601-11e8-ae97-52543be04c81": "UeD0Zma}Isj[NNfQoIaz0TfQxpa#-MazWZj@","86465baa-c84e-11e8-a54a-52543be04c81": "UnD}rAo1WpsUsUa|fQjt2Ea|o1WpN]jtfQa|","a21c098e-9bca-11e8-a767-52543be04c81": "UgRC;}xu%Me.j[fkj[fQ~qV@M{S2ozfQayay","932eb148-e6f6-11e9-a96c-52543be04c81": "UUMy|4340e61@_J6OqNZ0dwg%gxa^kNZMxSz","960c5b08-0601-11e8-ae97-52543be04c81": "UIQt:mL:-6DXM7MQy7V^^]XQERr@t3bZWWaz","9605eeee-0601-11e8-ae97-52543be04c81": "UHRovnMb?u,,t6ayj?j[_NxB9FElxtoKWXWB","9606ff74-0601-11e8-ae97-52543be04c81": "USQvUeoz.mnO-VkCOrV@?^aeZ%ozo}ae%1o}","960d31ec-0601-11e8-ae97-52543be04c81": "UcFs=1t70KWBt7fQRjay9FWB%Mj[j[fQfQof","96060e5f-0601-11e8-ae97-52543be04c81": "UMRxvfxX%HxX~ORmIsWDs-odE6Rm0Sod%Ht4","9640db63-0601-11e8-ae97-52543be04c81": "UHNBSPJ24,?bxt9WWBIm53-rNFD~-q%4fQ-r","692a3b69-0f68-11ea-a87e-52543be04c81": "UWBptsj[M{WBM|fQj[j[00ayxuof%MfQWBay","96073ec8-0601-11e8-ae97-52543be04c81": "UcOnX+D4-;%#MdyXVskC%gjZozRPe.f6o}RP","960b77af-0601-11e8-ae97-52543be04c81": "UP9R-gv#a0bbazj@j[a|0hO?o}jFkCWXWVjs","431eb0c9-c84c-11e8-a54a-52543be04c81": "UnD}rAo1WpsUsUa|fQjt2Ea|o1WpN]jtfQa|","960ea123-0601-11e8-ae97-52543be04c81": "UcR-3QozMJiwnifQfkfPHqadROkXoKfQf+fQ","9608c0e3-0601-11e8-ae97-52543be04c81": "UC85{3xuIURjM|oLofWB0KRPxut7-;WBRjt7","961fea46-0601-11e8-ae97-52543be04c81": "UVL1X*-j#7so}:TFsAaz{dt5KiRl%1kBRknj","961bd831-0601-11e8-ae97-52543be04c81": "UWS=#UofyqjtofkCayaL*IayMKj[aeaKkCkp","9614bbb6-0601-11e8-ae97-52543be04c81": "UJIXjn{zveTJofxuogs:0_K%yEa0t8s:t6WV","961d8738-0601-11e8-ae97-52543be04c81": "UK8:C^W:5OsVa#o2j?WV0^jZ^9WqobWoaiso","6fdd6fbf-1148-11ea-a87e-52543be04c81": "UzO:;7of?dj?t5WBtRoe%NoeM_ay%MazM|js","3a678190-738c-4a6d-b171-512aba7f1f53": "UZQWU$so=0=Jw{Wpo1o1|_fQNujt$PjtWpo1","961fa288-0601-11e8-ae97-52543be04c81": "USF;a[s;S0j]0KayWBayXyWVs;ofVxs;s;R%","70f691c6-7d88-11e9-aa30-52543be04c81": "UjKLj|jE~Ubc9cazt6oe^%bIs+n}kEoe${Rk","96266006-0601-11e8-ae97-52543be04c81": "UhQm9lof%Mj[WBj[j[ay~qj[M{j[xuayWBj[","960d063e-0601-11e8-ae97-52543be04c81": "USA-PvxaElS5o$jEaya}0:Ne$yslNFW=oLj]","960ed987-0601-11e8-ae97-52543be04c81": "UQL26=I:8wt7^k$*IAR*4.IU%gxuMdnOtRtl","960b1967-0601-11e8-ae97-52543be04c81": "UUS$P]tRozaeo}j[j[bH.mV@V@ozn4WBayjF","31074f8a-e6f4-11e9-a96c-52543be04c81": "UpNTWS9hN5Ia~MM}IrNHkFt5R*odRlWBocWB","914883fb-a7a1-11e9-a787-52543be04c81": "UQLNcQxu9GM|C8%LRkM|L#%LjZM{KkxtozM|","6ad4b88f-e6ed-11e9-a96c-52543be04c81": "UZPy#u1b7eA;_%JRKONa63%2xGsU?vM{RPRj","b6672d7f-6fcc-11e9-af37-52543be04c81": "U20A9TflflkEfle-fkf,Zeflfkacacfmf6e-","960c85ae-0601-11e8-ae97-52543be04c81": "U~R-*gRjbHt7*Jj[fQfQn4t7f6V[Vsayfkj["} diff --git a/src/components/Main.vue b/src/components/Main.vue index a6c8e2d..becc27f 100644 --- a/src/components/Main.vue +++ b/src/components/Main.vue @@ -73,10 +73,12 @@ export default { } }, }, + created() { + this.loadSettings() + }, mounted() { this.loadStations() this.scroll() - this.$store.dispatch('getMenuState') }, methods: { async onRoute() { @@ -204,6 +206,9 @@ export default { } } }, + loadSettings() { + this.$store.dispatch('getVolumeState') + }, }, } diff --git a/src/components/Player.vue b/src/components/Player.vue index ec7d65b..09e67bb 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -20,7 +20,8 @@ max="1" step=".05" :value="player.volume" - @input="changeVolume($event)"> + @input="changeVolume($event)" + @change="saveVolume($event)"> {{ player.title }} @@ -38,6 +39,9 @@ export default { changeVolume() { this.$store.dispatch('changeVolume', event.target.value) }, + saveVolume() { + this.$store.dispatch('setVolumeState', event.target.value) + }, toggleMute() { this.$store.dispatch('toggleMute') }, diff --git a/src/router.js b/src/router.js index 6e384c9..4c6d0a9 100644 --- a/src/router.js +++ b/src/router.js @@ -1,20 +1,17 @@ import Vue from 'vue' import Router from 'vue-router' import { generateUrl } from '@nextcloud/router' +import axios from '@nextcloud/axios' import Main from './components/Main' Vue.use(Router) -export default new Router({ +const router = new Router({ mode: 'history', base: generateUrl('/apps/radio'), linkActiveClass: 'active', routes: [ - { - path: '/', - redirect: '/top', - }, { path: '/top', component: Main, @@ -42,3 +39,20 @@ export default new Router({ }, ], }) + +router.beforeEach((to, from, next) => { + if (to.name) { + next() + } else { + axios + .get(generateUrl('/apps/radio/settings/menuState')) + .then(async response => { + const { + data: { menuState: value }, + } = response + next({ name: value }) + }) + } +}) + +export default router diff --git a/src/store.js b/src/store.js index b206d84..612047d 100644 --- a/src/store.js +++ b/src/store.js @@ -13,10 +13,11 @@ export default new Vuex.Store({ isBuffering: false, isMute: false, isPaused: false, - volume: 0, + volume: 0.5, oldVolume: 0, title: 'test', }, + menu: 'top', }, mutations: { isPlaying(state, playerState) { @@ -55,14 +56,29 @@ export default new Vuex.Store({ menuState, }) }, - getMenuState(state, menuState) { + getMenuState(state) { axios .get(generateUrl('/apps/radio/settings/menuState')) .then(async response => { const { data: { menuState: value }, } = response - console.log(value) + state.menu = value + }) + }, + setVolumeState(state, volumeState) { + axios.post(generateUrl('/apps/radio/settings/volumeState'), { + volumeState, + }) + }, + getVolumeState(state) { + axios + .get(generateUrl('/apps/radio/settings/volumeState')) + .then(async response => { + const { + data: { volumeState: value }, + } = response + state.player.volume = value }) }, }, @@ -91,5 +107,11 @@ export default new Vuex.Store({ getMenuState(context) { context.commit('getMenuState') }, + setVolumeState(context, volumeState) { + context.commit('setVolumeState', volumeState) + }, + getVolumeState(context) { + context.commit('getVolumeState') + }, }, })