@xhub-reels/sdk 0.1.13 → 0.1.14
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/index.cjs +29 -6
- package/dist/index.js +29 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1420,7 +1420,7 @@ function useHls(options) {
|
|
|
1420
1420
|
}
|
|
1421
1421
|
if (isNative) {
|
|
1422
1422
|
if (currentSrcRef.current === src) {
|
|
1423
|
-
if (video.readyState >= HTMLMediaElement.
|
|
1423
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1424
1424
|
setIsReady(true);
|
|
1425
1425
|
return void 0;
|
|
1426
1426
|
}
|
|
@@ -1428,7 +1428,7 @@ function useHls(options) {
|
|
|
1428
1428
|
video.addEventListener("canplay", handleCanPlayReuse, { once: true });
|
|
1429
1429
|
video.addEventListener("loadeddata", handleCanPlayReuse, { once: true });
|
|
1430
1430
|
video.addEventListener("playing", handleCanPlayReuse, { once: true });
|
|
1431
|
-
if (
|
|
1431
|
+
if (video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1432
1432
|
video.load();
|
|
1433
1433
|
}
|
|
1434
1434
|
return () => {
|
|
@@ -1439,7 +1439,10 @@ function useHls(options) {
|
|
|
1439
1439
|
}
|
|
1440
1440
|
video.src = src;
|
|
1441
1441
|
currentSrcRef.current = src;
|
|
1442
|
-
if (
|
|
1442
|
+
if (!isActive) {
|
|
1443
|
+
video.load();
|
|
1444
|
+
}
|
|
1445
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1443
1446
|
setIsReady(true);
|
|
1444
1447
|
return void 0;
|
|
1445
1448
|
}
|
|
@@ -1834,6 +1837,7 @@ function VideoSlotInner({
|
|
|
1834
1837
|
if (!video) return;
|
|
1835
1838
|
let onReady = null;
|
|
1836
1839
|
let fallbackTimerId = null;
|
|
1840
|
+
let pollId = null;
|
|
1837
1841
|
if (isActive) {
|
|
1838
1842
|
wasActiveRef.current = true;
|
|
1839
1843
|
const startPlay = () => {
|
|
@@ -1847,6 +1851,10 @@ function VideoSlotInner({
|
|
|
1847
1851
|
clearTimeout(fallbackTimerId);
|
|
1848
1852
|
fallbackTimerId = null;
|
|
1849
1853
|
}
|
|
1854
|
+
if (pollId !== null) {
|
|
1855
|
+
clearInterval(pollId);
|
|
1856
|
+
pollId = null;
|
|
1857
|
+
}
|
|
1850
1858
|
video.muted = true;
|
|
1851
1859
|
video.play().then(() => {
|
|
1852
1860
|
video.muted = isMuted;
|
|
@@ -1854,22 +1862,33 @@ function VideoSlotInner({
|
|
|
1854
1862
|
video.muted = isMuted;
|
|
1855
1863
|
});
|
|
1856
1864
|
};
|
|
1857
|
-
if (video.readyState >= HTMLMediaElement.
|
|
1865
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1858
1866
|
startPlay();
|
|
1859
1867
|
} else {
|
|
1860
1868
|
onReady = startPlay;
|
|
1861
1869
|
video.addEventListener("canplay", onReady, { once: true });
|
|
1862
1870
|
video.addEventListener("loadeddata", onReady, { once: true });
|
|
1863
1871
|
video.addEventListener("playing", onReady, { once: true });
|
|
1864
|
-
if (isNativeHls && video.src && video.readyState < HTMLMediaElement.
|
|
1872
|
+
if (isNativeHls && video.src && video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1865
1873
|
video.load();
|
|
1866
1874
|
}
|
|
1875
|
+
if (isNativeHls) {
|
|
1876
|
+
pollId = setInterval(() => {
|
|
1877
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA && onReady) {
|
|
1878
|
+
if (pollId !== null) {
|
|
1879
|
+
clearInterval(pollId);
|
|
1880
|
+
pollId = null;
|
|
1881
|
+
}
|
|
1882
|
+
startPlay();
|
|
1883
|
+
}
|
|
1884
|
+
}, 100);
|
|
1885
|
+
}
|
|
1867
1886
|
fallbackTimerId = window.setTimeout(() => {
|
|
1868
1887
|
fallbackTimerId = null;
|
|
1869
1888
|
if (onReady) {
|
|
1870
1889
|
startPlay();
|
|
1871
1890
|
}
|
|
1872
|
-
}, 3e3);
|
|
1891
|
+
}, isNativeHls ? 800 : 3e3);
|
|
1873
1892
|
}
|
|
1874
1893
|
} else if (wasActiveRef.current) {
|
|
1875
1894
|
video.pause();
|
|
@@ -1889,6 +1908,10 @@ function VideoSlotInner({
|
|
|
1889
1908
|
clearTimeout(fallbackTimerId);
|
|
1890
1909
|
fallbackTimerId = null;
|
|
1891
1910
|
}
|
|
1911
|
+
if (pollId !== null) {
|
|
1912
|
+
clearInterval(pollId);
|
|
1913
|
+
pollId = null;
|
|
1914
|
+
}
|
|
1892
1915
|
};
|
|
1893
1916
|
}, [isActive, isMuted, hasPlayedAhead, isNativeHls]);
|
|
1894
1917
|
react.useEffect(() => {
|
package/dist/index.js
CHANGED
|
@@ -1414,7 +1414,7 @@ function useHls(options) {
|
|
|
1414
1414
|
}
|
|
1415
1415
|
if (isNative) {
|
|
1416
1416
|
if (currentSrcRef.current === src) {
|
|
1417
|
-
if (video.readyState >= HTMLMediaElement.
|
|
1417
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1418
1418
|
setIsReady(true);
|
|
1419
1419
|
return void 0;
|
|
1420
1420
|
}
|
|
@@ -1422,7 +1422,7 @@ function useHls(options) {
|
|
|
1422
1422
|
video.addEventListener("canplay", handleCanPlayReuse, { once: true });
|
|
1423
1423
|
video.addEventListener("loadeddata", handleCanPlayReuse, { once: true });
|
|
1424
1424
|
video.addEventListener("playing", handleCanPlayReuse, { once: true });
|
|
1425
|
-
if (
|
|
1425
|
+
if (video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1426
1426
|
video.load();
|
|
1427
1427
|
}
|
|
1428
1428
|
return () => {
|
|
@@ -1433,7 +1433,10 @@ function useHls(options) {
|
|
|
1433
1433
|
}
|
|
1434
1434
|
video.src = src;
|
|
1435
1435
|
currentSrcRef.current = src;
|
|
1436
|
-
if (
|
|
1436
|
+
if (!isActive) {
|
|
1437
|
+
video.load();
|
|
1438
|
+
}
|
|
1439
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1437
1440
|
setIsReady(true);
|
|
1438
1441
|
return void 0;
|
|
1439
1442
|
}
|
|
@@ -1828,6 +1831,7 @@ function VideoSlotInner({
|
|
|
1828
1831
|
if (!video) return;
|
|
1829
1832
|
let onReady = null;
|
|
1830
1833
|
let fallbackTimerId = null;
|
|
1834
|
+
let pollId = null;
|
|
1831
1835
|
if (isActive) {
|
|
1832
1836
|
wasActiveRef.current = true;
|
|
1833
1837
|
const startPlay = () => {
|
|
@@ -1841,6 +1845,10 @@ function VideoSlotInner({
|
|
|
1841
1845
|
clearTimeout(fallbackTimerId);
|
|
1842
1846
|
fallbackTimerId = null;
|
|
1843
1847
|
}
|
|
1848
|
+
if (pollId !== null) {
|
|
1849
|
+
clearInterval(pollId);
|
|
1850
|
+
pollId = null;
|
|
1851
|
+
}
|
|
1844
1852
|
video.muted = true;
|
|
1845
1853
|
video.play().then(() => {
|
|
1846
1854
|
video.muted = isMuted;
|
|
@@ -1848,22 +1856,33 @@ function VideoSlotInner({
|
|
|
1848
1856
|
video.muted = isMuted;
|
|
1849
1857
|
});
|
|
1850
1858
|
};
|
|
1851
|
-
if (video.readyState >= HTMLMediaElement.
|
|
1859
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1852
1860
|
startPlay();
|
|
1853
1861
|
} else {
|
|
1854
1862
|
onReady = startPlay;
|
|
1855
1863
|
video.addEventListener("canplay", onReady, { once: true });
|
|
1856
1864
|
video.addEventListener("loadeddata", onReady, { once: true });
|
|
1857
1865
|
video.addEventListener("playing", onReady, { once: true });
|
|
1858
|
-
if (isNativeHls && video.src && video.readyState < HTMLMediaElement.
|
|
1866
|
+
if (isNativeHls && video.src && video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1859
1867
|
video.load();
|
|
1860
1868
|
}
|
|
1869
|
+
if (isNativeHls) {
|
|
1870
|
+
pollId = setInterval(() => {
|
|
1871
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA && onReady) {
|
|
1872
|
+
if (pollId !== null) {
|
|
1873
|
+
clearInterval(pollId);
|
|
1874
|
+
pollId = null;
|
|
1875
|
+
}
|
|
1876
|
+
startPlay();
|
|
1877
|
+
}
|
|
1878
|
+
}, 100);
|
|
1879
|
+
}
|
|
1861
1880
|
fallbackTimerId = window.setTimeout(() => {
|
|
1862
1881
|
fallbackTimerId = null;
|
|
1863
1882
|
if (onReady) {
|
|
1864
1883
|
startPlay();
|
|
1865
1884
|
}
|
|
1866
|
-
}, 3e3);
|
|
1885
|
+
}, isNativeHls ? 800 : 3e3);
|
|
1867
1886
|
}
|
|
1868
1887
|
} else if (wasActiveRef.current) {
|
|
1869
1888
|
video.pause();
|
|
@@ -1883,6 +1902,10 @@ function VideoSlotInner({
|
|
|
1883
1902
|
clearTimeout(fallbackTimerId);
|
|
1884
1903
|
fallbackTimerId = null;
|
|
1885
1904
|
}
|
|
1905
|
+
if (pollId !== null) {
|
|
1906
|
+
clearInterval(pollId);
|
|
1907
|
+
pollId = null;
|
|
1908
|
+
}
|
|
1886
1909
|
};
|
|
1887
1910
|
}, [isActive, isMuted, hasPlayedAhead, isNativeHls]);
|
|
1888
1911
|
useEffect(() => {
|