l-min-components 1.7.1471 → 1.7.1472
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
|
@@ -87,8 +87,8 @@ const VideoPlayer2 = ({
|
|
|
87
87
|
setCount(count + 1);
|
|
88
88
|
}
|
|
89
89
|
if (videoRef?.current) {
|
|
90
|
-
const currentTime = videoRef.current
|
|
91
|
-
const duration = videoRef.current
|
|
90
|
+
const currentTime = videoRef.current?.currentTime;
|
|
91
|
+
const duration = videoRef.current?.duration;
|
|
92
92
|
const played = currentTime / duration;
|
|
93
93
|
|
|
94
94
|
setRangeProgress(played);
|
|
@@ -126,8 +126,8 @@ const VideoPlayer2 = ({
|
|
|
126
126
|
const handlePause = () => setIsPlaying(false);
|
|
127
127
|
const handleEnded = () => setIsPlaying(false);
|
|
128
128
|
const handleTimeUpdate = () => {
|
|
129
|
-
const currentTime = video
|
|
130
|
-
const duration = video
|
|
129
|
+
const currentTime = video?.currentTime;
|
|
130
|
+
const duration = video?.duration;
|
|
131
131
|
|
|
132
132
|
const played = currentTime / duration;
|
|
133
133
|
setProgress({
|
|
@@ -144,23 +144,23 @@ const VideoPlayer2 = ({
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
const attachEvents = () => {
|
|
147
|
-
video
|
|
148
|
-
video
|
|
149
|
-
video
|
|
150
|
-
video
|
|
151
|
-
video
|
|
147
|
+
video?.addEventListener("play", handlePlay);
|
|
148
|
+
video?.addEventListener("pause", handlePause);
|
|
149
|
+
video?.addEventListener("ended", handleEnded);
|
|
150
|
+
video?.addEventListener("timeupdate", handleTimeUpdate);
|
|
151
|
+
video?.addEventListener("waiting", handleWaiting);
|
|
152
152
|
if (streamUrl && !src) {
|
|
153
|
-
video
|
|
153
|
+
video?.addEventListener("canplay", handleCanPlay);
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
const detachEvents = () => {
|
|
158
|
-
video
|
|
159
|
-
video
|
|
160
|
-
video
|
|
161
|
-
video
|
|
162
|
-
video
|
|
163
|
-
video
|
|
158
|
+
video?.removeEventListener("play", handlePlay);
|
|
159
|
+
video?.removeEventListener("pause", handlePause);
|
|
160
|
+
video?.removeEventListener("ended", handleEnded);
|
|
161
|
+
video?.removeEventListener("timeupdate", handleTimeUpdate);
|
|
162
|
+
video?.removeEventListener("waiting", handleWaiting);
|
|
163
|
+
video?.removeEventListener("canplay", handleCanPlay);
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
if (!src && Hls.isSupported()) {
|
|
@@ -173,48 +173,50 @@ const VideoPlayer2 = ({
|
|
|
173
173
|
lowLatencyMode: true,
|
|
174
174
|
});
|
|
175
175
|
|
|
176
|
-
hls
|
|
177
|
-
hls
|
|
178
|
-
hls
|
|
176
|
+
hls?.attachMedia(video);
|
|
177
|
+
hls?.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
178
|
+
hls?.loadSource(url);
|
|
179
179
|
});
|
|
180
180
|
|
|
181
|
-
hls
|
|
181
|
+
hls?.on(Hls.Events.LEVEL_SWITCHED, (val) => {
|
|
182
182
|
if (val === "hlsLevelSwitched") {
|
|
183
183
|
setIsReady(true);
|
|
184
184
|
setError(null);
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
|
-
hls
|
|
187
|
+
hls?.on(Hls.Events.LEVEL_LOADING, (val) => {
|
|
188
188
|
if (val === "hlsLevelLoading") {
|
|
189
189
|
setIsReady(false);
|
|
190
190
|
}
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
hls
|
|
194
|
-
hls
|
|
195
|
-
hls
|
|
193
|
+
hls?.on(Hls.Events.BUFFER_STALLED, () => setIsBuffering(true));
|
|
194
|
+
hls?.on(Hls.Events.BUFFER_APPENDED, () => setIsBuffering(false));
|
|
195
|
+
hls?.on(Hls.Events.BUFFER_CREATED, (val) => {
|
|
196
196
|
if (val === "hlsBufferCreated") {
|
|
197
197
|
setIsBuffering(true);
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
-
hls
|
|
201
|
+
hls?.on(Hls.Events.BUFFER_APPENDED, (val) => {
|
|
202
202
|
if (val === "hlsBufferAppended") {
|
|
203
203
|
setIsBuffering(false);
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
hls
|
|
207
|
+
hls?.on(Hls.Events.ERROR, (event, data) => {
|
|
208
208
|
console.warn("HLS error", data);
|
|
209
209
|
if (data.fatal) {
|
|
210
210
|
setError(data);
|
|
211
211
|
setIsReady(false);
|
|
212
212
|
if (data.type === Hls.ErrorTypes.NETWORK_ERROR) {
|
|
213
|
-
hls
|
|
213
|
+
hls?.startLoad();
|
|
214
214
|
} else if (data.type === Hls.ErrorTypes.MEDIA_ERROR) {
|
|
215
|
-
hls
|
|
215
|
+
hls?.recoverMediaError();
|
|
216
216
|
} else {
|
|
217
|
-
hls.destroy
|
|
217
|
+
if (hls && typeof hls.destroy === "function") {
|
|
218
|
+
hls?.destroy();
|
|
219
|
+
}
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
});
|
|
@@ -234,7 +236,7 @@ const VideoPlayer2 = ({
|
|
|
234
236
|
attachEvents();
|
|
235
237
|
return () => {
|
|
236
238
|
if (hls && typeof hls.destroy === "function") {
|
|
237
|
-
hls
|
|
239
|
+
hls?.destroy();
|
|
238
240
|
}
|
|
239
241
|
detachEvents();
|
|
240
242
|
};
|