[web] Add lyrics player to the webinterface

Update icons.js
Add icons in alphabetical order.
Change comment to remove reference to external website
Remove extra line feeds

Co-Authored-by: Alain Nussbaumer <alain.nussbaumer@alleluia.ch>
This commit is contained in:
X-Ryl669
2023-09-21 18:53:20 +02:00
parent 83ac327d7f
commit 5e370e479a
14 changed files with 340 additions and 28 deletions

View File

@@ -33,6 +33,12 @@ export default createStore({
item_length_ms: 0,
item_progress_ms: 0
},
lyrics: {
found: false,
lyrics_id: -1,
lyrics_pane: false,
lyrics: []
},
queue: {
version: 0,
count: 0,
@@ -70,6 +76,18 @@ export default createStore({
},
getters: {
lyrics: (state) => {
return state.lyrics.lyrics
},
lyrics_found: (state) => {
return state.lyrics.found
},
lyrics_pane: (state) => {
return state.lyrics.lyrics_pane
},
now_playing: (state) => {
const item = state.queue.items.find(function (item) {
return item.id === state.player.item_id
@@ -188,6 +206,28 @@ export default createStore({
[types.UPDATE_QUEUE](state, queue) {
state.queue = queue
},
[types.UPDATE_LYRICS](state, lyrics) {
// Parse from .LRC or text format to synchronized lyrics
function parse(lyrics) {
let lyricsObj = []
let tempArr = lyrics.split('\n')
const regex = /(\[(\d+):(\d+)(?:\.\d+)?\] ?)?(.*)/
tempArr.forEach((item) => {
let matches = regex.exec(item)
if (matches !== null && matches[4].length) {
let obj = [matches[4]]
if (matches[2] != null && matches[3] != null)
obj.push(parseInt(matches[2], 10) * 60 + parseInt(matches[3], 10))
lyricsObj.push(obj)
}
})
return lyricsObj
}
state.lyrics.lyrics = 'lyrics' in lyrics ? parse(lyrics.lyrics) : ''
if (!state.lyrics.found)
state.lyrics.found = state.lyrics.lyrics.length > 0
},
[types.UPDATE_LASTFM](state, lastfm) {
state.lastfm = lastfm
},

View File

@@ -8,6 +8,7 @@ export const UPDATE_LIBRARY_RSS_COUNT = 'UPDATE_LIBRARY_RSS_COUNT'
export const UPDATE_OUTPUTS = 'UPDATE_OUTPUTS'
export const UPDATE_PLAYER_STATUS = 'UPDATE_PLAYER_STATUS'
export const UPDATE_QUEUE = 'UPDATE_QUEUE'
export const UPDATE_LYRICS = 'UPDATE_LYRICS'
export const UPDATE_LASTFM = 'UPDATE_LASTFM'
export const UPDATE_SPOTIFY = 'UPDATE_SPOTIFY'
export const UPDATE_PAIRING = 'UPDATE_PAIRING'