diff --git a/front/src/EmbedFrame.vue b/front/src/EmbedFrame.vue index 06b90a729..3fcef4e8f 100644 --- a/front/src/EmbedFrame.vue +++ b/front/src/EmbedFrame.vue @@ -29,59 +29,7 @@

{{ currentTrack.title }}

{{ currentTrack.artist.name }} -
- -
- Widget improperly configured (bad resource type {{ type }}). - Widget improperly configured (missing resource id). - Track not found. - You need to login to access this resource. - A server error occurred. - An unknown error occurred while loading track data from server. - This track is unavailable. - An unknown error occurred while loading track data. -
- - - -
+
@@ -119,6 +67,7 @@ import axios from 'axios' import Logo from "@/components/Logo" import url from '@/utils/url' import time from '@/utils/time' +import Player from '@/components/audio/PlayerCopy' function getURLParams () { var urlParams @@ -135,7 +84,7 @@ function getURLParams () { } export default { name: 'app', - components: {Logo}, + components: {Logo, Player}, data () { return { time, @@ -175,6 +124,7 @@ export default { if (!!params.instance) { this.baseUrl = params.instance } + this.$store.dispatch('instance/setUrl', this.baseUrl) this.autoplay = params.autoplay != undefined || params.auto_play != undefined this.fetch(this.type, this.id) @@ -256,7 +206,9 @@ export default { let self = this let url = `${this.baseUrl}/api/v1/tracks/${id}/` axios.get(url).then(response => { - self.tracks = self.parseTracks([response.data]) + self.tracks = response.data + self.$store.dispatch('queue/append', {track: self.tracks}) + self.$store.dispatch('queue/next') self.isLoading = false; }).catch(error => { if (error.response) { @@ -326,9 +278,9 @@ export default { }, bindEvents () { let self = this - this.$refs.player.player.on('ended', () => { - self.next() - }) + //this.$refs.player.player.on('ended', () => { + // self.next() + //}) }, fullUrl (path) { if (path.startsWith('/')) { diff --git a/front/src/components/audio/PlayerCopy.vue b/front/src/components/audio/PlayerCopy.vue new file mode 100644 index 000000000..8dd712f90 --- /dev/null +++ b/front/src/components/audio/PlayerCopy.vue @@ -0,0 +1,731 @@ + + + diff --git a/front/src/embed.js b/front/src/embed.js index 8a7c1522f..dfda51f40 100644 --- a/front/src/embed.js +++ b/front/src/embed.js @@ -1,12 +1,57 @@ import Vue from 'vue' +import Vuex from 'vuex' import EmbedFrame from './EmbedFrame' +import locales from '@/locales' +import player from '@/store/player' +import queue from '@/store/queue' +import instance from '@/store/instance' +import GetTextPlugin from 'vue-gettext' -Vue.config.productionTip = false +//Vue.config.productionTip = false +Vue.use(Vuex) + +const store = new Vuex.Store({ + modules: { + player, + queue, + instance + } +}) + +let availableLanguages = (function () { + let l = {} + locales.locales.forEach(c => { + l[c.code] = c.label + }) + return l +})() +let defaultLanguage = 'en_US' +//if (availableLanguages[store.state.ui.currentLanguage]) { +// defaultLanguage = store.state.ui.currentLanguage +//} +Vue.use(GetTextPlugin, { + availableLanguages: availableLanguages, + defaultLanguage: defaultLanguage, + // cf https://github.com/Polyconseil/vue-gettext#configuration + // not recommended but this is fixing weird bugs with translation nodes + // not being updated when in v-if/v-else clauses + autoAddKeyAttributes: true, + languageVmMixin: { + computed: { + currentKebabCase: function () { + return this.current.toLowerCase().replace('_', '-') + } + } + }, + translations: {}, + silent: true +}) /* eslint-disable no-new */ new Vue({ el: '#app', + store, render (h) { return h('EmbedFrame') },