l-min-components 1.0.1131 → 1.0.1135

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.0.1131",
3
+ "version": "1.0.1135",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -7,7 +7,7 @@ const useAudioPlayer = ({ src, streamSrc }) => {
7
7
  const [isPlaying, setIsPlaying] = useState(false);
8
8
  const [isBuffering, setIsBuffering] = useState(false);
9
9
  const [isReady, setIsReady] = useState(false);
10
- const [error, setError] = useState(false);
10
+ const [error, setError] = useState(null);
11
11
  const [progress, setProgress] = useState({});
12
12
 
13
13
  const { accessToken, generalData } = useContext(OutletContext);
@@ -47,7 +47,7 @@ const useAudioPlayer = ({ src, streamSrc }) => {
47
47
  });
48
48
 
49
49
  hls.on(Hls.Events.ERROR, (event, data) => {
50
- setError(true);
50
+ setError(data);
51
51
  });
52
52
  } else if (!src && audio.canPlayType("application/vnd.apple.mpegurl")) {
53
53
  audio.src = streamSrc;
@@ -62,7 +62,17 @@ const useAudioPlayer = ({ src, streamSrc }) => {
62
62
  }
63
63
  }
64
64
  const handleEnded = () => setIsPlaying(false);
65
+
66
+ const handlePlaying = () => {
67
+ setIsPlaying(true);
68
+ };
69
+ const handlePause = () => {
70
+ setIsPlaying(false);
71
+ };
72
+
65
73
  audio.addEventListener("ended", handleEnded);
74
+ audio.addEventListener("playing", handlePlaying);
75
+ audio.addEventListener("pause", handlePause);
66
76
 
67
77
  const handleProgress = () => {
68
78
  if (audio) {
@@ -84,18 +94,22 @@ const useAudioPlayer = ({ src, streamSrc }) => {
84
94
  const play = () => {
85
95
  if (audioRef.current) {
86
96
  audioRef.current.play();
87
- setIsPlaying(true);
88
97
  }
89
98
  };
90
99
 
91
100
  const pause = () => {
92
101
  if (audioRef.current) {
93
102
  audioRef.current.pause();
94
- setIsPlaying(false);
95
103
  }
96
104
  };
97
-
105
+ const stop = () => {
106
+ if (audioRef.current) {
107
+ audioRef.current.pause();
108
+ audioRef.current.currentTime = 0;
109
+ }
110
+ };
98
111
  return {
112
+ stop,
99
113
  audioRef,
100
114
  play,
101
115
  pause,