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:
@@ -31,7 +31,12 @@ export default createStore({
|
||||
volume: 0,
|
||||
item_id: 0,
|
||||
item_length_ms: 0,
|
||||
item_progress_ms: 0
|
||||
item_progress_ms: 0,
|
||||
},
|
||||
lyrics: {
|
||||
lyrics_pane: false,
|
||||
lyrics_id: -1,
|
||||
lyrics: []
|
||||
},
|
||||
queue: {
|
||||
version: 0,
|
||||
@@ -70,6 +75,14 @@ export default createStore({
|
||||
},
|
||||
|
||||
getters: {
|
||||
lyrics_pane: (state) => {
|
||||
return state.lyrics.lyrics_pane
|
||||
},
|
||||
|
||||
lyrics: (state) => {
|
||||
return state.lyrics.lyrics
|
||||
},
|
||||
|
||||
now_playing: (state) => {
|
||||
const item = state.queue.items.find(function (item) {
|
||||
return item.id === state.player.item_id
|
||||
@@ -188,6 +201,26 @@ 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) : ""
|
||||
},
|
||||
[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