lrc-audio-player 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -440,8 +440,13 @@ function useLyricPlayer(options) {
440
440
  }
441
441
  setPlayer(instance);
442
442
  setLines(instance.lines);
443
- setDuration(instance.duration);
444
443
  setIsLoading(false);
444
+ if (!isNaN(instance.duration)) {
445
+ setDuration(instance.duration);
446
+ }
447
+ instance.audio.addEventListener("loadedmetadata", () => {
448
+ setDuration(instance.duration);
449
+ });
445
450
  instance.on("linechange", (line, index) => {
446
451
  setCurrentLine(line);
447
452
  setCurrentIndex(index);
package/dist/react.js CHANGED
@@ -48,8 +48,13 @@ function useLyricPlayer(options) {
48
48
  }
49
49
  setPlayer(instance);
50
50
  setLines(instance.lines);
51
- setDuration(instance.duration);
52
51
  setIsLoading(false);
52
+ if (!isNaN(instance.duration)) {
53
+ setDuration(instance.duration);
54
+ }
55
+ instance.audio.addEventListener("loadedmetadata", () => {
56
+ setDuration(instance.duration);
57
+ });
53
58
  instance.on("linechange", (line, index) => {
54
59
  setCurrentLine(line);
55
60
  setCurrentIndex(index);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lrc-audio-player",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Sync LRC/word-level lyrics to an HTML audio element with one constructor. Includes an optional React hook at lrc-audio-player/react.",
5
5
  "repository": {
6
6
  "type": "git",