完善歌词
parent
f2b6c0a443
commit
c66d7d6187
|
@ -2,7 +2,7 @@ const path = require('path')
|
||||||
const os = require('os')
|
const os = require('os')
|
||||||
|
|
||||||
const defaultSetting = {
|
const defaultSetting = {
|
||||||
version: '1.0.39',
|
version: '1.0.40',
|
||||||
player: {
|
player: {
|
||||||
togglePlayMethod: 'listLoop',
|
togglePlayMethod: 'listLoop',
|
||||||
highQuality: false,
|
highQuality: false,
|
||||||
|
@ -11,7 +11,8 @@ const defaultSetting = {
|
||||||
isMute: false,
|
isMute: false,
|
||||||
mediaDeviceId: 'default',
|
mediaDeviceId: 'default',
|
||||||
isMediaDeviceRemovedStopPlay: false,
|
isMediaDeviceRemovedStopPlay: false,
|
||||||
isShowLyricTransition: true,
|
isShowLyricTransition: false,
|
||||||
|
isPlayLxlrc: true,
|
||||||
isSavePlayTime: false,
|
isSavePlayTime: false,
|
||||||
},
|
},
|
||||||
desktopLyric: {
|
desktopLyric: {
|
||||||
|
|
|
@ -14,6 +14,7 @@ const setLrcConfig = () => {
|
||||||
config: desktopLyric,
|
config: desktopLyric,
|
||||||
languageId: global.appSetting.langId,
|
languageId: global.appSetting.langId,
|
||||||
isShowLyricTransition: global.appSetting.player.isShowLyricTransition,
|
isShowLyricTransition: global.appSetting.player.isShowLyricTransition,
|
||||||
|
isPlayLxlrc: global.appSetting.player.isPlayLxlrc,
|
||||||
})
|
})
|
||||||
if (isLock != desktopLyric.isLock) {
|
if (isLock != desktopLyric.isLock) {
|
||||||
isLock = desktopLyric.isLock
|
isLock = desktopLyric.isLock
|
||||||
|
|
|
@ -24,7 +24,12 @@ mainOn(ipcWinLyricNames.set_lyric_config, (event, config) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
mainHandle(ipcWinLyricNames.get_lyric_config, async() => {
|
||||||
return { config: global.appSetting.desktopLyric, languageId: global.appSetting.langId, isShowLyricTransition: global.appSetting.player.isShowLyricTransition }
|
return {
|
||||||
|
config: global.appSetting.desktopLyric,
|
||||||
|
languageId: global.appSetting.langId,
|
||||||
|
isShowLyricTransition: global.appSetting.player.isShowLyricTransition,
|
||||||
|
isPlayLxlrc: global.appSetting.player.isPlayLxlrc,
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
mainOn(ipcWinLyricNames.set_win_bounds, (event, options) => {
|
mainOn(ipcWinLyricNames.set_win_bounds, (event, options) => {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
|
transition(enter-active-class="animated-fast fadeIn" leave-active-class="animated-fast fadeOut")
|
||||||
.control-bar(v-show="!lrcConfig.isLock")
|
.control-bar(v-show="!lrcConfig.isLock")
|
||||||
core-control-bar(:lrcConfig="lrcConfig" :themes="themeList")
|
core-control-bar(:lrcConfig="lrcConfig" :themes="themeList")
|
||||||
core-lyric(:lrcConfig="lrcConfig" :isShowLyricTransition="isShowLyricTransition")
|
core-lyric(:lrcConfig="lrcConfig" :isPlayLxlrc="isPlayLxlrc" :isShowLyricTransition="isShowLyricTransition")
|
||||||
div.resize-left(@mousedown.self="handleMouseDown('left', $event)")
|
div.resize-left(@mousedown.self="handleMouseDown('left', $event)")
|
||||||
div.resize-top(@mousedown.self="handleMouseDown('top', $event)")
|
div.resize-top(@mousedown.self="handleMouseDown('top', $event)")
|
||||||
div.resize-right(@mousedown.self="handleMouseDown('right', $event)")
|
div.resize-right(@mousedown.self="handleMouseDown('right', $event)")
|
||||||
|
@ -45,6 +45,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
isShowLyricTransition: true,
|
isShowLyricTransition: true,
|
||||||
|
isPlayLxlrc: true,
|
||||||
themeList: [
|
themeList: [
|
||||||
{
|
{
|
||||||
id: 0,
|
id: 0,
|
||||||
|
@ -118,9 +119,10 @@ export default {
|
||||||
document.removeEventListener('mouseup', this.handleMouseUp)
|
document.removeEventListener('mouseup', this.handleMouseUp)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleUpdateConfig({ config, languageId, isShowLyricTransition }) {
|
handleUpdateConfig({ config, languageId, isShowLyricTransition, isPlayLxlrc }) {
|
||||||
this.lrcConfig = config
|
this.lrcConfig = config
|
||||||
this.isShowLyricTransition = isShowLyricTransition
|
this.isShowLyricTransition = isShowLyricTransition
|
||||||
|
this.isPlayLxlrc = isPlayLxlrc
|
||||||
if (this.$i18n.locale !== languageId && languageId != null) this.$i18n.locale = languageId
|
if (this.$i18n.locale !== languageId && languageId != null) this.$i18n.locale = languageId
|
||||||
},
|
},
|
||||||
handleMouseDown(origin, event) {
|
handleMouseDown(origin, event) {
|
||||||
|
|
|
@ -28,6 +28,10 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
isPlayLxlrc: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
isShowLyricTransition: {
|
isShowLyricTransition: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
|
@ -122,8 +126,11 @@ export default {
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
isShowLyricTransition(n) {
|
isShowLyricTransition() {
|
||||||
console.log(n)
|
this.setLyric()
|
||||||
|
rendererSend(NAMES.winLyric.get_lyric_info, 'status')
|
||||||
|
},
|
||||||
|
isPlayLxlrc() {
|
||||||
this.setLyric()
|
this.setLyric()
|
||||||
rendererSend(NAMES.winLyric.get_lyric_info, 'status')
|
rendererSend(NAMES.winLyric.get_lyric_info, 'status')
|
||||||
},
|
},
|
||||||
|
@ -226,8 +233,10 @@ export default {
|
||||||
cancelScrollFn = scrollTo(this.$refs.dom_lyric, dom_p ? (dom_p.offsetTop - this.$refs.dom_lyric.clientHeight * 0.5 + dom_p.clientHeight / 2) : 0)
|
cancelScrollFn = scrollTo(this.$refs.dom_lyric, dom_p ? (dom_p.offsetTop - this.$refs.dom_lyric.clientHeight * 0.5 + dom_p.clientHeight / 2) : 0)
|
||||||
},
|
},
|
||||||
handleLyricMouseDown(e) {
|
handleLyricMouseDown(e) {
|
||||||
console.log(e.target)
|
if (e.target.classList.contains('font') ||
|
||||||
if (e.target.classList.contains('font') || e.target.parentNode.classList.contains('font')) {
|
e.target.parentNode.classList.contains('font') ||
|
||||||
|
e.target.classList.contains('translation') ||
|
||||||
|
e.target.parentNode.classList.contains('translation')) {
|
||||||
this.lyricEvent.isMsDown = true
|
this.lyricEvent.isMsDown = true
|
||||||
this.lyricEvent.msDownY = e.clientY
|
this.lyricEvent.msDownY = e.clientY
|
||||||
this.lyricEvent.msDownScrollY = this.$refs.dom_lyric.scrollTop
|
this.lyricEvent.msDownScrollY = this.$refs.dom_lyric.scrollTop
|
||||||
|
@ -296,7 +305,8 @@ export default {
|
||||||
},
|
},
|
||||||
setLyric() {
|
setLyric() {
|
||||||
window.lrc.setLyric(
|
window.lrc.setLyric(
|
||||||
this.lyrics.lxlyric ? this.lyrics.lxlyric : this.lyrics.lyric,
|
this.isPlayLxlrc && this.lyrics.lxlyric ? this.lyrics.lxlyric : this.lyrics.lyric,
|
||||||
|
this.isShowLyricTransition && this.lyrics.tlyric ? this.lyrics.tlyric : '',
|
||||||
// (this.isShowLyricTransition && this.lyrics.tlyric ? (this.lyrics.tlyric + '\n') : '') + (this.lyrics.lyric || ''),
|
// (this.isShowLyricTransition && this.lyrics.tlyric ? (this.lyrics.tlyric + '\n') : '') + (this.lyrics.lyric || ''),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -327,6 +337,13 @@ export default {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.translation {
|
||||||
|
transition: @transition-theme !important;
|
||||||
|
transition-property: font-size, color;
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.line {
|
.line {
|
||||||
transition-property: font-size, color !important;
|
transition-property: font-size, color !important;
|
||||||
background: none !important;
|
background: none !important;
|
||||||
|
@ -337,6 +354,10 @@ export default {
|
||||||
.line {
|
.line {
|
||||||
color: @color-theme;
|
color: @color-theme;
|
||||||
}
|
}
|
||||||
|
.translation {
|
||||||
|
font-size: 1em;
|
||||||
|
color: @color-theme;
|
||||||
|
}
|
||||||
span {
|
span {
|
||||||
// color: @color-theme;
|
// color: @color-theme;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
|
|
|
@ -275,6 +275,9 @@ export default {
|
||||||
'setting.player.isShowLyricTransition'() {
|
'setting.player.isShowLyricTransition'() {
|
||||||
this.setLyric()
|
this.setLyric()
|
||||||
},
|
},
|
||||||
|
'setting.player.isPlayLxlrc'() {
|
||||||
|
this.setLyric()
|
||||||
|
},
|
||||||
async list(n, o) {
|
async list(n, o) {
|
||||||
if (n === o && this.musicInfo.songmid) {
|
if (n === o && this.musicInfo.songmid) {
|
||||||
let index = this.listId == 'download'
|
let index = this.listId == 'download'
|
||||||
|
@ -856,7 +859,8 @@ export default {
|
||||||
},
|
},
|
||||||
setLyric() {
|
setLyric() {
|
||||||
window.lrc.setLyric(
|
window.lrc.setLyric(
|
||||||
this.musicInfo.lxlrc ? this.musicInfo.lxlrc : this.musicInfo.lrc,
|
this.setting.player.isPlayLxlrc && this.musicInfo.lxlrc ? this.musicInfo.lxlrc : this.musicInfo.lrc,
|
||||||
|
this.setting.player.isShowLyricTransition && this.musicInfo.tlrc ? this.musicInfo.tlrc : '',
|
||||||
// (
|
// (
|
||||||
// this.setting.player.isShowLyricTransition && this.musicInfo.tlrc
|
// this.setting.player.isShowLyricTransition && this.musicInfo.tlrc
|
||||||
// ? (this.musicInfo.tlrc + '\n')
|
// ? (this.musicInfo.tlrc + '\n')
|
||||||
|
|
|
@ -589,6 +589,12 @@ export default {
|
||||||
margin: 16px 0;
|
margin: 16px 0;
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
|
|
||||||
|
.translation {
|
||||||
|
transition: @transition-theme !important;
|
||||||
|
transition-property: font-size, color;
|
||||||
|
font-size: 1em;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
.line {
|
.line {
|
||||||
transition-property: font-size, color !important;
|
transition-property: font-size, color !important;
|
||||||
background: none !important;
|
background: none !important;
|
||||||
|
@ -599,6 +605,10 @@ export default {
|
||||||
.line {
|
.line {
|
||||||
color: @color-theme;
|
color: @color-theme;
|
||||||
}
|
}
|
||||||
|
.translation {
|
||||||
|
font-size: 1.2em;
|
||||||
|
color: @color-theme;
|
||||||
|
}
|
||||||
span {
|
span {
|
||||||
// color: @color-theme;
|
// color: @color-theme;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"play": "Play",
|
"play": "Play",
|
||||||
"play_save_play_time": "Remember playback progress",
|
"play_save_play_time": "Remember playback progress",
|
||||||
"play_lyric_transition": "Show lyrics translation",
|
"play_lyric_transition": "Show lyrics translation",
|
||||||
|
"play_lyric_lxlrc": "Use Karaoke-style lyrics playback (if supported)",
|
||||||
"play_quality": "Play 320K quality songs first (if supported)",
|
"play_quality": "Play 320K quality songs first (if supported)",
|
||||||
"play_task_bar": "Show playing progress on the taskbar",
|
"play_task_bar": "Show playing progress on the taskbar",
|
||||||
"play_mediaDevice_title": "Select a media device for audio output",
|
"play_mediaDevice_title": "Select a media device for audio output",
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"play": "播放设置",
|
"play": "播放设置",
|
||||||
"play_save_play_time": "记住播放进度",
|
"play_save_play_time": "记住播放进度",
|
||||||
"play_lyric_transition": "显示歌词翻译",
|
"play_lyric_transition": "显示歌词翻译",
|
||||||
|
"play_lyric_lxlrc": "使用卡拉OK式歌词播放(如果支持)",
|
||||||
"play_quality": "优先播放320K品质的歌曲(如果支持)",
|
"play_quality": "优先播放320K品质的歌曲(如果支持)",
|
||||||
"play_task_bar": "在任务栏上显示当前歌曲播放进度",
|
"play_task_bar": "在任务栏上显示当前歌曲播放进度",
|
||||||
"play_mediaDevice_title": "选择声音输出的媒体设备",
|
"play_mediaDevice_title": "选择声音输出的媒体设备",
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
"play": "播放設置",
|
"play": "播放設置",
|
||||||
"play_save_play_time": "記住播放進度",
|
"play_save_play_time": "記住播放進度",
|
||||||
"play_lyric_transition": "顯示歌詞翻譯",
|
"play_lyric_transition": "顯示歌詞翻譯",
|
||||||
|
"play_lyric_lxlrc": "使用卡拉OK式歌詞播放(如果支持)",
|
||||||
"play_quality": "優先播放320K品質的歌曲(如果支持)",
|
"play_quality": "優先播放320K品質的歌曲(如果支持)",
|
||||||
"play_task_bar": "在任務欄上顯示當前歌曲播放進度",
|
"play_task_bar": "在任務欄上顯示當前歌曲播放進度",
|
||||||
"play_mediaDevice_title": "選擇聲音輸出的媒體設備",
|
"play_mediaDevice_title": "選擇聲音輸出的媒體設備",
|
||||||
|
|
|
@ -20,11 +20,13 @@ const createAnimation = (dom, duration) => new window.Animation(new window.Keyfr
|
||||||
// https://jsfiddle.net/ceqpnbky/1/
|
// https://jsfiddle.net/ceqpnbky/1/
|
||||||
|
|
||||||
module.exports = class FontPlayer {
|
module.exports = class FontPlayer {
|
||||||
constructor({ lyric = '', lineClassName = '', fontClassName = '', lineModeClassName = '', shadowContent = false, shadowClassName = '' }) {
|
constructor({ lyric = '', translationLyric = '', lineClassName = '', fontClassName = '', translationClassName = '', lineModeClassName = '', shadowContent = false, shadowClassName = '' }) {
|
||||||
this.lyric = lyric
|
this.lyric = lyric
|
||||||
|
this.translationLyric = translationLyric
|
||||||
|
|
||||||
this.lineClassName = lineClassName
|
this.lineClassName = lineClassName
|
||||||
this.fontClassName = fontClassName
|
this.fontClassName = fontClassName
|
||||||
|
this.translationClassName = translationClassName
|
||||||
this.lineModeClassName = lineModeClassName
|
this.lineModeClassName = lineModeClassName
|
||||||
this.shadowContent = shadowContent
|
this.shadowContent = shadowContent
|
||||||
this.shadowClassName = shadowClassName
|
this.shadowClassName = shadowClassName
|
||||||
|
@ -49,17 +51,33 @@ module.exports = class FontPlayer {
|
||||||
this.isLineMode = false
|
this.isLineMode = false
|
||||||
|
|
||||||
this.lineContent = document.createElement('div')
|
this.lineContent = document.createElement('div')
|
||||||
this.lineContent.style = 'position:relative;'
|
|
||||||
if (this.lineClassName) this.lineContent.classList.add(this.lineClassName)
|
if (this.lineClassName) this.lineContent.classList.add(this.lineClassName)
|
||||||
this.fontContent = document.createElement('div')
|
this.fontContent = document.createElement('div')
|
||||||
|
this.fontContent.style = 'position:relative;display:inline-block;'
|
||||||
if (this.fontClassName) this.fontContent.classList.add(this.fontClassName)
|
if (this.fontClassName) this.fontContent.classList.add(this.fontClassName)
|
||||||
if (this.shadowContent) {
|
if (this.shadowContent) {
|
||||||
this.fontShadowContent = document.createElement('div')
|
this.fontShadowContent = document.createElement('div')
|
||||||
this.fontShadowContent.style = 'position:absolute;top:0;left:0;width:100%;z-index:-1;'
|
this.fontShadowContent.style = 'position:absolute;top:0;left:0;width:100%;z-index:-1;'
|
||||||
this.fontShadowContent.className = this.shadowClassName
|
this.fontShadowContent.className = this.shadowClassName
|
||||||
this.lineContent.appendChild(this.fontShadowContent)
|
this.fontContent.appendChild(this.fontShadowContent)
|
||||||
}
|
}
|
||||||
this.lineContent.appendChild(this.fontContent)
|
this.lineContent.appendChild(this.fontContent)
|
||||||
|
if (this.translationLyric) {
|
||||||
|
this.translationContent = document.createElement('div')
|
||||||
|
this.translationContent.style = 'position:relative;display:inline-block;'
|
||||||
|
this.translationContent.className = this.translationClassName
|
||||||
|
this.translationContent.textContent = this.translationLyric
|
||||||
|
this.lineContent.appendChild(document.createElement('br'))
|
||||||
|
this.lineContent.appendChild(this.translationContent)
|
||||||
|
|
||||||
|
if (this.shadowContent) {
|
||||||
|
this.translationShadowContent = document.createElement('div')
|
||||||
|
this.translationShadowContent.style = 'position:absolute;top:0;left:0;width:100%;z-index:-1;'
|
||||||
|
this.translationShadowContent.className = this.shadowClassName
|
||||||
|
this.translationShadowContent.textContent = this.translationLyric
|
||||||
|
this.translationContent.appendChild(this.translationShadowContent)
|
||||||
|
}
|
||||||
|
}
|
||||||
this._parseLyric()
|
this._parseLyric()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,11 @@ const fontTimeExp = /<(\d+),(\d+)>/g
|
||||||
module.exports = class Lyric {
|
module.exports = class Lyric {
|
||||||
constructor({
|
constructor({
|
||||||
lyric = '',
|
lyric = '',
|
||||||
|
translationLyric = '',
|
||||||
offset = 150,
|
offset = 150,
|
||||||
lineClassName = '',
|
lineClassName = '',
|
||||||
fontClassName = 'font',
|
fontClassName = 'font',
|
||||||
|
translationClassName = 'translation',
|
||||||
activeLineClassName = 'active',
|
activeLineClassName = 'active',
|
||||||
lineModeClassName = 'line',
|
lineModeClassName = 'line',
|
||||||
shadowClassName = '',
|
shadowClassName = '',
|
||||||
|
@ -17,12 +19,14 @@ module.exports = class Lyric {
|
||||||
onSetLyric = function() { },
|
onSetLyric = function() { },
|
||||||
}) {
|
}) {
|
||||||
this.lyric = lyric
|
this.lyric = lyric
|
||||||
|
this.translationLyric = translationLyric
|
||||||
this.offset = offset
|
this.offset = offset
|
||||||
this.onPlay = onPlay
|
this.onPlay = onPlay
|
||||||
this.onSetLyric = onSetLyric
|
this.onSetLyric = onSetLyric
|
||||||
|
|
||||||
this.lineClassName = lineClassName
|
this.lineClassName = lineClassName
|
||||||
this.fontClassName = fontClassName
|
this.fontClassName = fontClassName
|
||||||
|
this.translationClassName = translationClassName
|
||||||
this.activeLineClassName = activeLineClassName
|
this.activeLineClassName = activeLineClassName
|
||||||
this.lineModeClassName = lineModeClassName
|
this.lineModeClassName = lineModeClassName
|
||||||
this.shadowClassName = shadowClassName
|
this.shadowClassName = shadowClassName
|
||||||
|
@ -37,10 +41,11 @@ module.exports = class Lyric {
|
||||||
this.isLineMode = false
|
this.isLineMode = false
|
||||||
|
|
||||||
if (this.linePlayer) {
|
if (this.linePlayer) {
|
||||||
this.linePlayer.setLyric(this.lyric)
|
this.linePlayer.setLyric(this.lyric, this.translationLyric)
|
||||||
} else {
|
} else {
|
||||||
this.linePlayer = new LinePlayer({
|
this.linePlayer = new LinePlayer({
|
||||||
lyric: this.lyric,
|
lyric: this.lyric,
|
||||||
|
translationLyric: this.translationLyric,
|
||||||
offset: this.offset,
|
offset: this.offset,
|
||||||
onPlay: this._handleLinePlayerOnPlay,
|
onPlay: this._handleLinePlayerOnPlay,
|
||||||
onSetLyric: this._handleLinePlayerOnSetLyric,
|
onSetLyric: this._handleLinePlayerOnSetLyric,
|
||||||
|
@ -93,6 +98,7 @@ module.exports = class Lyric {
|
||||||
}
|
}
|
||||||
|
|
||||||
_handleLinePlayerOnSetLyric = lyricLines => {
|
_handleLinePlayerOnSetLyric = lyricLines => {
|
||||||
|
// console.log(lyricLines)
|
||||||
// this._lines = lyricsLines
|
// this._lines = lyricsLines
|
||||||
this.isLineMode = lyricLines.length && !/^<\d+,\d+>/.test(lyricLines[0].text)
|
this.isLineMode = lyricLines.length && !/^<\d+,\d+>/.test(lyricLines[0].text)
|
||||||
|
|
||||||
|
@ -101,8 +107,10 @@ module.exports = class Lyric {
|
||||||
this._lines = lyricLines.map(line => {
|
this._lines = lyricLines.map(line => {
|
||||||
const fontPlayer = new FontPlayer({
|
const fontPlayer = new FontPlayer({
|
||||||
lyric: line.text,
|
lyric: line.text,
|
||||||
|
translationLyric: line.translation,
|
||||||
lineClassName: this.lineClassName,
|
lineClassName: this.lineClassName,
|
||||||
fontClassName: this.fontClassName,
|
fontClassName: this.fontClassName,
|
||||||
|
translationClassName: this.translationClassName,
|
||||||
lineModeClassName: this.lineModeClassName,
|
lineModeClassName: this.lineModeClassName,
|
||||||
shadowClassName: this.shadowClassName,
|
shadowClassName: this.shadowClassName,
|
||||||
shadowContent: this.shadowContent,
|
shadowContent: this.shadowContent,
|
||||||
|
@ -119,8 +127,10 @@ module.exports = class Lyric {
|
||||||
this._lines = lyricLines.map(line => {
|
this._lines = lyricLines.map(line => {
|
||||||
const fontPlayer = new FontPlayer({
|
const fontPlayer = new FontPlayer({
|
||||||
lyric: line.text,
|
lyric: line.text,
|
||||||
|
translationLyric: line.translation,
|
||||||
lineClassName: this.lineClassName,
|
lineClassName: this.lineClassName,
|
||||||
fontClassName: this.fontClassName,
|
fontClassName: this.fontClassName,
|
||||||
|
translationClassName: this.translationClassName,
|
||||||
shadowClassName: this.shadowClassName,
|
shadowClassName: this.shadowClassName,
|
||||||
shadowContent: this.shadowContent,
|
shadowContent: this.shadowContent,
|
||||||
})
|
})
|
||||||
|
@ -148,8 +158,9 @@ module.exports = class Lyric {
|
||||||
if (this.playingLineNum > -1) this._lineFonts[this.playingLineNum].pause()
|
if (this.playingLineNum > -1) this._lineFonts[this.playingLineNum].pause()
|
||||||
}
|
}
|
||||||
|
|
||||||
setLyric(lyric) {
|
setLyric(lyric, translationLyric) {
|
||||||
this.lyric = lyric
|
this.lyric = lyric
|
||||||
|
this.translationLyric = translationLyric
|
||||||
this._init()
|
this._init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,12 @@ const tagRegMap = {
|
||||||
const timeoutTools = new TimeoutTools()
|
const timeoutTools = new TimeoutTools()
|
||||||
|
|
||||||
module.exports = class LinePlayer {
|
module.exports = class LinePlayer {
|
||||||
constructor({ lyric = '', offset = 0, onPlay = function() { }, onSetLyric = function() { } } = {}) {
|
constructor({ lyric = '', translationLyric = '', offset = 0, onPlay = function() { }, onSetLyric = function() { } } = {}) {
|
||||||
this.lyric = lyric
|
this.lyric = lyric
|
||||||
|
this.translationLyric = translationLyric
|
||||||
this.tags = {}
|
this.tags = {}
|
||||||
this.lines = null
|
this.lines = null
|
||||||
|
this.translationLines = null
|
||||||
this.onPlay = onPlay
|
this.onPlay = onPlay
|
||||||
this.onSetLyric = onSetLyric
|
this.onSetLyric = onSetLyric
|
||||||
this.isPlay = false
|
this.isPlay = false
|
||||||
|
@ -30,6 +32,7 @@ module.exports = class LinePlayer {
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
if (this.lyric == null) this.lyric = ''
|
if (this.lyric == null) this.lyric = ''
|
||||||
|
if (this.translationLyric == null) this.translationLyric = ''
|
||||||
this._initTag()
|
this._initTag()
|
||||||
this._initLines()
|
this._initLines()
|
||||||
this.onSetLyric(this.lines)
|
this.onSetLyric(this.lines)
|
||||||
|
@ -44,26 +47,45 @@ module.exports = class LinePlayer {
|
||||||
|
|
||||||
_initLines() {
|
_initLines() {
|
||||||
this.lines = []
|
this.lines = []
|
||||||
|
this.translationLines = []
|
||||||
const lines = this.lyric.split('\n')
|
const lines = this.lyric.split('\n')
|
||||||
|
const linesMap = {}
|
||||||
|
// const translationLines = this.translationLyric.split('\n')
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
const line = lines[i].trim()
|
const line = lines[i].trim()
|
||||||
let result = timeExp.exec(line)
|
let result = timeExp.exec(line)
|
||||||
if (result) {
|
if (result) {
|
||||||
const text = line.replace(timeExp, '').trim()
|
const text = line.replace(timeExp, '').trim()
|
||||||
if (text) {
|
if (text) {
|
||||||
const timeArr = RegExp.$1.split(':')
|
const timeStr = RegExp.$1
|
||||||
|
const timeArr = timeStr.split(':')
|
||||||
if (timeArr.length < 3) timeArr.unshift(0)
|
if (timeArr.length < 3) timeArr.unshift(0)
|
||||||
if (timeArr[2].indexOf('.') > -1) {
|
if (timeArr[2].indexOf('.') > -1) {
|
||||||
timeArr.push(...timeArr[2].split('.'))
|
timeArr.push(...timeArr[2].split('.'))
|
||||||
timeArr.splice(2, 1)
|
timeArr.splice(2, 1)
|
||||||
}
|
}
|
||||||
this.lines.push({
|
linesMap[timeStr] = {
|
||||||
time: parseInt(timeArr[0]) * 60 * 60 * 1000 + parseInt(timeArr[1]) * 60 * 1000 + parseInt(timeArr[2]) * 1000 + parseInt(timeArr[3] || 0),
|
time: parseInt(timeArr[0]) * 60 * 60 * 1000 + parseInt(timeArr[1]) * 60 * 1000 + parseInt(timeArr[2]) * 1000 + parseInt(timeArr[3] || 0),
|
||||||
text,
|
text,
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const translationLines = this.translationLyric.split('\n')
|
||||||
|
for (let i = 0; i < translationLines.length; i++) {
|
||||||
|
const line = translationLines[i].trim()
|
||||||
|
let result = timeExp.exec(line)
|
||||||
|
if (result) {
|
||||||
|
const text = line.replace(timeExp, '').trim()
|
||||||
|
if (text) {
|
||||||
|
const timeStr = RegExp.$1
|
||||||
|
const targetLine = linesMap[timeStr]
|
||||||
|
if (targetLine) targetLine.translation = text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.lines = Object.values(linesMap)
|
||||||
this.lines.sort((a, b) => {
|
this.lines.sort((a, b) => {
|
||||||
return a.time - b.time
|
return a.time - b.time
|
||||||
})
|
})
|
||||||
|
@ -145,9 +167,11 @@ module.exports = class LinePlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setLyric(lyric) {
|
setLyric(lyric, translationLyric) {
|
||||||
|
console.log(translationLyric)
|
||||||
if (this.isPlay) this.pause()
|
if (this.isPlay) this.pause()
|
||||||
this.lyric = lyric
|
this.lyric = lyric
|
||||||
|
this.translationLyric = translationLyric
|
||||||
this._init()
|
this._init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,8 @@ div.scroll(:class="$style.setting" ref="dom_setting")
|
||||||
material-checkbox(id="setting_player_save_play_time" v-model="current_setting.player.isSavePlayTime" :label="$t('view.setting.play_save_play_time')")
|
material-checkbox(id="setting_player_save_play_time" v-model="current_setting.player.isSavePlayTime" :label="$t('view.setting.play_save_play_time')")
|
||||||
div(:class="$style.gapTop")
|
div(:class="$style.gapTop")
|
||||||
material-checkbox(id="setting_player_lyric_transition" v-model="current_setting.player.isShowLyricTransition" :label="$t('view.setting.play_lyric_transition')")
|
material-checkbox(id="setting_player_lyric_transition" v-model="current_setting.player.isShowLyricTransition" :label="$t('view.setting.play_lyric_transition')")
|
||||||
|
div(:class="$style.gapTop")
|
||||||
|
material-checkbox(id="setting_player_lyric_play_lxlrc" v-model="current_setting.player.isPlayLxlrc" :label="$t('view.setting.play_lyric_lxlrc')")
|
||||||
div(:class="$style.gapTop")
|
div(:class="$style.gapTop")
|
||||||
material-checkbox(id="setting_player_highQuality" v-model="current_setting.player.highQuality" :label="$t('view.setting.play_quality')")
|
material-checkbox(id="setting_player_highQuality" v-model="current_setting.player.highQuality" :label="$t('view.setting.play_quality')")
|
||||||
div(:class="$style.gapTop")
|
div(:class="$style.gapTop")
|
||||||
|
@ -606,6 +608,9 @@ export default {
|
||||||
'setting.player.togglePlayMethod'(n) {
|
'setting.player.togglePlayMethod'(n) {
|
||||||
this.current_setting.player.togglePlayMethod = n
|
this.current_setting.player.togglePlayMethod = n
|
||||||
},
|
},
|
||||||
|
// 'setting.player.isPlayLxlrc'(n) {
|
||||||
|
// this.current_setting.player.isPlayLxlrc = n
|
||||||
|
// },
|
||||||
'current_setting.player.isShowTaskProgess'(n) {
|
'current_setting.player.isShowTaskProgess'(n) {
|
||||||
if (n) return
|
if (n) return
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
|
Loading…
Reference in New Issue