LyricLine.ts 845 B

12345678910111213141516171819202122232425262728
  1. import { LyricWord } from './LyricWord'
  2. /**
  3. * The line info of lyric.
  4. */
  5. export class LyricLine {
  6. text: string
  7. readonly beginTime: number
  8. nextTime: number
  9. words: LyricWord[] = []
  10. translation?: string; // 存储翻译文本
  11. /**
  12. * @param text The text of lyric line.
  13. * @param beginTime The begin timestamp of this lyric line.
  14. * @param nextTime The begin timestamp of the next lyric line.
  15. */
  16. constructor(text: string, beginTime: number, nextTime: number,words?: LyricWord[],translation?: string ) {
  17. this.text = text
  18. this.beginTime = beginTime
  19. this.nextTime = nextTime
  20. this.words = words || []
  21. this.translation = translation || ''
  22. }
  23. // 新增方法:判断是否有逐字歌词
  24. hasWords(): boolean {
  25. return this.words.length > 0
  26. }
  27. }