mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-10 22:10:15 -05:00
[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:
@@ -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
|
||||
},
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user