Extension.ts 750 B

123456789101112131415161718192021222324252627282930
  1. import hilog from '@ohos.hilog';
  2. const TAG = "LyricView"
  3. export function printD(msg: string) {
  4. hilog.debug(0, TAG, msg)
  5. }
  6. export function printW(msg: string) {
  7. hilog.warn(0, TAG, msg)
  8. }
  9. export function duration2text(duration: number): string {
  10. let seconds = Math.round(duration / 1000)
  11. let minute = Math.floor(seconds / 60)
  12. let second = seconds - minute * 60
  13. let s1 = minute.toString()
  14. let s2 = second >= 10 ? second.toString() : "0" + second
  15. return s1 + ":" + s2
  16. }
  17. export function seconds2text(seconds: number) {
  18. let minute = Math.floor(seconds / 60)
  19. let second = seconds - minute * 60
  20. if (second < 10) {
  21. return minute + ":0" + second
  22. } else {
  23. return minute + ":" + second
  24. }
  25. }