lyrics working
This commit is contained in:
parent
7179ed6361
commit
83ce79046e
2 changed files with 13 additions and 10 deletions
|
@ -319,7 +319,7 @@
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
</div>
|
||||||
<div class="app-drawer" v-if="drawertest">
|
<div class="app-drawer" v-if="drawertest">
|
||||||
<lyrics-view v-if="drawertest && lyricon"></lyrics-view>
|
<lyrics-view v-if="drawertest && lyricon" :time="lyriccurrenttime" :lyrics="lyrics"></lyrics-view>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -600,16 +600,16 @@
|
||||||
</script>
|
</script>
|
||||||
<script type="text/x-template" id="lyrics-view">
|
<script type="text/x-template" id="lyrics-view">
|
||||||
<div class="md-body lyric-body">
|
<div class="md-body lyric-body">
|
||||||
<template v-if="app.lyrics">
|
<template v-if="lyrics">
|
||||||
<template v-for="lyric in app.lyrics" v-if="lyric.line != 'lrcInstrumental'">
|
<template v-for="lyric in lyrics" v-if="lyric.line != 'lrcInstrumental'">
|
||||||
<h3 class="lyric-line" @click="app.seekTo(lyric.startTime, false)"
|
<h3 class="lyric-line" @click="app.seekTo(lyric.startTime, false)"
|
||||||
:class="app.getLyricClass(lyric.startTime, lyric.endTime)">
|
v-bind:class="{ active: app.getLyricClass(lyric.startTime, lyric.endTime)}">
|
||||||
{{ lyric.line }}
|
{{ lyric.line }}
|
||||||
</h3>
|
</h3>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<h3 class="lyric-line" @click="app.seekTo(lyric.startTime, false)"
|
<h3 class="lyric-line" @click="app.seekTo(lyric.startTime, false)"
|
||||||
:class="app.getLyricClass(lyric.startTime, lyric.endTime)">
|
v-bind:class="{ active: app.getLyricClass(lyric.startTime, lyric.endTime)}">
|
||||||
<div class="lyricWaiting">
|
<div class="lyricWaiting">
|
||||||
<div></div>
|
<div></div>
|
||||||
<div></div>
|
<div></div>
|
||||||
|
|
|
@ -53,6 +53,7 @@ Vue.component('mediaitem-list-item', {
|
||||||
|
|
||||||
Vue.component('lyrics-view', {
|
Vue.component('lyrics-view', {
|
||||||
template: '#lyrics-view',
|
template: '#lyrics-view',
|
||||||
|
props: ["time", "lyrics"],
|
||||||
methods: {}
|
methods: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -128,6 +129,7 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
lyricon: false,
|
lyricon: false,
|
||||||
lyrics: [],
|
lyrics: [],
|
||||||
|
lyriccurrenttime: 0,
|
||||||
lyricsMediaItem: {},
|
lyricsMediaItem: {},
|
||||||
lyricsDebug: {
|
lyricsDebug: {
|
||||||
current: 0,
|
current: 0,
|
||||||
|
@ -155,10 +157,12 @@ const app = new Vue({
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
this.mk.addEventListener(MusicKit.Events.playbackTimeDidChange, (a) => {
|
||||||
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)
|
self.playerLCD.playbackDuration = (self.mk.currentPlaybackTime)
|
||||||
|
self.lyriccurrenttime = app.mk.currentPlaybackTime;
|
||||||
})
|
})
|
||||||
|
|
||||||
this.mk.addEventListener(MusicKit.Events.nowPlayingItemDidChange, (a) => {
|
this.mk.addEventListener(MusicKit.Events.nowPlayingItemDidChange, (a) => {
|
||||||
self.chrome.artworkReady = false
|
self.chrome.artworkReady = false
|
||||||
|
self.lyrics = []
|
||||||
app.loadLyrics()
|
app.loadLyrics()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -360,9 +364,8 @@ const app = new Vue({
|
||||||
return parseFloat(this.hmsToSecondsOnly(this.parseTime(this.mk.nowPlayingItem.attributes.durationInMillis - app.mk.currentPlaybackTimeRemaining *1000)));
|
return parseFloat(this.hmsToSecondsOnly(this.parseTime(this.mk.nowPlayingItem.attributes.durationInMillis - app.mk.currentPlaybackTimeRemaining *1000)));
|
||||||
},
|
},
|
||||||
getLyricClass(start, end) {
|
getLyricClass(start, end) {
|
||||||
let currentTime = app.getCurrentTime();
|
//this.lyriccurrenttime = app.getCurrentTime();
|
||||||
// check if currenttime is between start and end
|
if (this.lyriccurrenttime >= start && this.lyriccurrenttime <= end) {
|
||||||
if (currentTime >= start && currentTime <= end) {
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (document.querySelector(".lyric-line.active")) {
|
if (document.querySelector(".lyric-line.active")) {
|
||||||
document.querySelector(".lyric-line.active").scrollIntoView({
|
document.querySelector(".lyric-line.active").scrollIntoView({
|
||||||
|
@ -371,9 +374,9 @@ const app = new Vue({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, 200)
|
}, 200)
|
||||||
return "active"
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return ""
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
seekTo(time){
|
seekTo(time){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue