l-min-components 1.7.1485 → 1.7.1487
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
|
@@ -469,7 +469,7 @@ const HeaderComponent = (props) => {
|
|
|
469
469
|
window.location.href = helpUrl;
|
|
470
470
|
}}
|
|
471
471
|
className={
|
|
472
|
-
window.location.pathname.includes("help
|
|
472
|
+
window.location.pathname.includes("help") ? "active" : ""
|
|
473
473
|
}
|
|
474
474
|
>
|
|
475
475
|
<QuestionMark /> {props?.findText("Help")}
|
|
@@ -26,11 +26,10 @@ const useAudioPlayer = ({ src, streamSrc }) => {
|
|
|
26
26
|
const [error, setError] = useState(null);
|
|
27
27
|
const [progress, setProgress] = useState({});
|
|
28
28
|
|
|
29
|
-
const url = useMemo(() =>
|
|
29
|
+
const url = useMemo(() => streamSrc || src, [src, streamSrc]);
|
|
30
30
|
const audio = useMemo(() => new Audio(), [url]);
|
|
31
31
|
|
|
32
32
|
const { accessToken, generalData } = useContext(OutletContext);
|
|
33
|
-
|
|
34
33
|
const accountId = generalData?.selectedAccount?.id;
|
|
35
34
|
|
|
36
35
|
const play = useCallback(() => {
|
|
@@ -61,12 +60,13 @@ const useAudioPlayer = ({ src, streamSrc }) => {
|
|
|
61
60
|
const handlePlay = () => setIsPlaying(true);
|
|
62
61
|
const handleProgress = () => {
|
|
63
62
|
if (audio) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
setProgress({
|
|
64
|
+
currentTime: audio.currentTime,
|
|
65
|
+
duration: audio.duration,
|
|
66
|
+
});
|
|
68
67
|
}
|
|
69
68
|
};
|
|
69
|
+
|
|
70
70
|
const attachAudioEvents = () => {
|
|
71
71
|
audio.addEventListener("ended", handleEnded);
|
|
72
72
|
audio.addEventListener("pause", handlePause);
|
|
@@ -76,15 +76,10 @@ const useAudioPlayer = ({ src, streamSrc }) => {
|
|
|
76
76
|
audio.addEventListener("waiting", () => setIsBuffering(true));
|
|
77
77
|
audio.addEventListener("canplay", () => setIsBuffering(false));
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
attachAudioEvents();
|
|
85
|
-
audio.load();
|
|
86
|
-
} else if (audio && accountId) {
|
|
87
|
-
if (Hls?.isSupported() && streamSrc && !src) {
|
|
79
|
+
|
|
80
|
+
if (audio && streamSrc && accountId && !src) {
|
|
81
|
+
// HLS stream preferred
|
|
82
|
+
if (Hls.isSupported()) {
|
|
88
83
|
hls = new Hls({
|
|
89
84
|
xhrSetup: function (xhr, url) {
|
|
90
85
|
const modifiedURL = `${url}?_account=${accountId}`;
|
|
@@ -94,10 +89,10 @@ const useAudioPlayer = ({ src, streamSrc }) => {
|
|
|
94
89
|
lowLatencyMode: true,
|
|
95
90
|
});
|
|
96
91
|
|
|
97
|
-
hls
|
|
92
|
+
hls.attachMedia(audio);
|
|
98
93
|
|
|
99
94
|
hls.on(Hls.Events.MEDIA_ATTACHED, () => {
|
|
100
|
-
hls.loadSource(
|
|
95
|
+
hls.loadSource(streamSrc);
|
|
101
96
|
});
|
|
102
97
|
|
|
103
98
|
hls.on(Hls.Events.LEVEL_LOADED, () => {
|
|
@@ -105,25 +100,6 @@ const useAudioPlayer = ({ src, streamSrc }) => {
|
|
|
105
100
|
setError(null);
|
|
106
101
|
});
|
|
107
102
|
|
|
108
|
-
hls.on(Hls.Events.LEVEL_SWITCHED, (val) => {
|
|
109
|
-
if (val === "hlsLevelSwitched") {
|
|
110
|
-
setIsReady(true);
|
|
111
|
-
setError(null);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
hls.on(Hls.Events.LEVEL_LOADING, (val) => {
|
|
115
|
-
if (val === "hlsLevelLoading") {
|
|
116
|
-
setIsReady(false);
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
hls.on(Hls?.Events?.BUFFER_STALLED, () => {
|
|
120
|
-
setIsBuffering(true);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
hls.on(Hls?.Events?.BUFFER_APPENDED, () => {
|
|
124
|
-
setIsBuffering(false);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
103
|
hls.on(Hls.Events.ERROR, (event, data) => {
|
|
128
104
|
console.warn("HLS error", data);
|
|
129
105
|
if (data.fatal) {
|
|
@@ -138,14 +114,22 @@ const useAudioPlayer = ({ src, streamSrc }) => {
|
|
|
138
114
|
}
|
|
139
115
|
}
|
|
140
116
|
});
|
|
141
|
-
} else if (
|
|
142
|
-
audio.src =
|
|
117
|
+
} else if (audio.canPlayType("application/vnd.apple.mpegurl")) {
|
|
118
|
+
audio.src = streamSrc;
|
|
143
119
|
audio.addEventListener("loadedmetadata", () => {
|
|
144
120
|
setIsReady(true);
|
|
145
121
|
});
|
|
146
122
|
}
|
|
147
123
|
attachAudioEvents();
|
|
124
|
+
} else if (audio && src) {
|
|
125
|
+
// Fallback to normal src
|
|
126
|
+
audio.src = src;
|
|
127
|
+
audio.addEventListener("loadedmetadata", () => {
|
|
128
|
+
setIsReady(true);
|
|
129
|
+
});
|
|
130
|
+
attachAudioEvents();
|
|
148
131
|
}
|
|
132
|
+
|
|
149
133
|
return () => {
|
|
150
134
|
if (hls) {
|
|
151
135
|
hls.destroy();
|