@xhub-reels/sdk 0.1.12 → 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 +53 -7
- package/dist/index.js +53 -7
- 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,6 +1428,9 @@ 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 (video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1432
|
+
video.load();
|
|
1433
|
+
}
|
|
1431
1434
|
return () => {
|
|
1432
1435
|
video.removeEventListener("canplay", handleCanPlayReuse);
|
|
1433
1436
|
video.removeEventListener("loadeddata", handleCanPlayReuse);
|
|
@@ -1436,7 +1439,10 @@ function useHls(options) {
|
|
|
1436
1439
|
}
|
|
1437
1440
|
video.src = src;
|
|
1438
1441
|
currentSrcRef.current = src;
|
|
1439
|
-
if (
|
|
1442
|
+
if (!isActive) {
|
|
1443
|
+
video.load();
|
|
1444
|
+
}
|
|
1445
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1440
1446
|
setIsReady(true);
|
|
1441
1447
|
return void 0;
|
|
1442
1448
|
}
|
|
@@ -1830,6 +1836,8 @@ function VideoSlotInner({
|
|
|
1830
1836
|
const video = videoRef.current;
|
|
1831
1837
|
if (!video) return;
|
|
1832
1838
|
let onReady = null;
|
|
1839
|
+
let fallbackTimerId = null;
|
|
1840
|
+
let pollId = null;
|
|
1833
1841
|
if (isActive) {
|
|
1834
1842
|
wasActiveRef.current = true;
|
|
1835
1843
|
const startPlay = () => {
|
|
@@ -1839,6 +1847,14 @@ function VideoSlotInner({
|
|
|
1839
1847
|
video.removeEventListener("playing", onReady);
|
|
1840
1848
|
onReady = null;
|
|
1841
1849
|
}
|
|
1850
|
+
if (fallbackTimerId !== null) {
|
|
1851
|
+
clearTimeout(fallbackTimerId);
|
|
1852
|
+
fallbackTimerId = null;
|
|
1853
|
+
}
|
|
1854
|
+
if (pollId !== null) {
|
|
1855
|
+
clearInterval(pollId);
|
|
1856
|
+
pollId = null;
|
|
1857
|
+
}
|
|
1842
1858
|
video.muted = true;
|
|
1843
1859
|
video.play().then(() => {
|
|
1844
1860
|
video.muted = isMuted;
|
|
@@ -1846,16 +1862,33 @@ function VideoSlotInner({
|
|
|
1846
1862
|
video.muted = isMuted;
|
|
1847
1863
|
});
|
|
1848
1864
|
};
|
|
1849
|
-
if (video.readyState >= HTMLMediaElement.
|
|
1865
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1850
1866
|
startPlay();
|
|
1851
1867
|
} else {
|
|
1852
1868
|
onReady = startPlay;
|
|
1853
1869
|
video.addEventListener("canplay", onReady, { once: true });
|
|
1854
1870
|
video.addEventListener("loadeddata", onReady, { once: true });
|
|
1855
1871
|
video.addEventListener("playing", onReady, { once: true });
|
|
1856
|
-
if (
|
|
1872
|
+
if (isNativeHls && video.src && video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1857
1873
|
video.load();
|
|
1858
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
|
+
}
|
|
1886
|
+
fallbackTimerId = window.setTimeout(() => {
|
|
1887
|
+
fallbackTimerId = null;
|
|
1888
|
+
if (onReady) {
|
|
1889
|
+
startPlay();
|
|
1890
|
+
}
|
|
1891
|
+
}, isNativeHls ? 800 : 3e3);
|
|
1859
1892
|
}
|
|
1860
1893
|
} else if (wasActiveRef.current) {
|
|
1861
1894
|
video.pause();
|
|
@@ -1871,13 +1904,25 @@ function VideoSlotInner({
|
|
|
1871
1904
|
video.removeEventListener("loadeddata", onReady);
|
|
1872
1905
|
video.removeEventListener("playing", onReady);
|
|
1873
1906
|
}
|
|
1907
|
+
if (fallbackTimerId !== null) {
|
|
1908
|
+
clearTimeout(fallbackTimerId);
|
|
1909
|
+
fallbackTimerId = null;
|
|
1910
|
+
}
|
|
1911
|
+
if (pollId !== null) {
|
|
1912
|
+
clearInterval(pollId);
|
|
1913
|
+
pollId = null;
|
|
1914
|
+
}
|
|
1874
1915
|
};
|
|
1875
1916
|
}, [isActive, isMuted, hasPlayedAhead, isNativeHls]);
|
|
1876
1917
|
react.useEffect(() => {
|
|
1877
1918
|
const video = videoRef.current;
|
|
1878
1919
|
if (!video) return;
|
|
1879
|
-
|
|
1880
|
-
|
|
1920
|
+
if (isActive) {
|
|
1921
|
+
video.muted = isMuted;
|
|
1922
|
+
} else {
|
|
1923
|
+
video.muted = true;
|
|
1924
|
+
}
|
|
1925
|
+
}, [isMuted, isActive]);
|
|
1881
1926
|
const [isActuallyPlaying, setIsActuallyPlaying] = react.useState(false);
|
|
1882
1927
|
react.useEffect(() => {
|
|
1883
1928
|
const video = videoRef.current;
|
|
@@ -1955,8 +2000,9 @@ function VideoSlotInner({
|
|
|
1955
2000
|
ref: videoRef,
|
|
1956
2001
|
src: mp4Src,
|
|
1957
2002
|
loop: true,
|
|
1958
|
-
muted:
|
|
2003
|
+
muted: true,
|
|
1959
2004
|
playsInline: true,
|
|
2005
|
+
autoPlay: isActive,
|
|
1960
2006
|
preload: shouldLoadSrc ? "auto" : "none",
|
|
1961
2007
|
style: {
|
|
1962
2008
|
width: "100%",
|
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,6 +1422,9 @@ 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 (video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1426
|
+
video.load();
|
|
1427
|
+
}
|
|
1425
1428
|
return () => {
|
|
1426
1429
|
video.removeEventListener("canplay", handleCanPlayReuse);
|
|
1427
1430
|
video.removeEventListener("loadeddata", handleCanPlayReuse);
|
|
@@ -1430,7 +1433,10 @@ function useHls(options) {
|
|
|
1430
1433
|
}
|
|
1431
1434
|
video.src = src;
|
|
1432
1435
|
currentSrcRef.current = src;
|
|
1433
|
-
if (
|
|
1436
|
+
if (!isActive) {
|
|
1437
|
+
video.load();
|
|
1438
|
+
}
|
|
1439
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1434
1440
|
setIsReady(true);
|
|
1435
1441
|
return void 0;
|
|
1436
1442
|
}
|
|
@@ -1824,6 +1830,8 @@ function VideoSlotInner({
|
|
|
1824
1830
|
const video = videoRef.current;
|
|
1825
1831
|
if (!video) return;
|
|
1826
1832
|
let onReady = null;
|
|
1833
|
+
let fallbackTimerId = null;
|
|
1834
|
+
let pollId = null;
|
|
1827
1835
|
if (isActive) {
|
|
1828
1836
|
wasActiveRef.current = true;
|
|
1829
1837
|
const startPlay = () => {
|
|
@@ -1833,6 +1841,14 @@ function VideoSlotInner({
|
|
|
1833
1841
|
video.removeEventListener("playing", onReady);
|
|
1834
1842
|
onReady = null;
|
|
1835
1843
|
}
|
|
1844
|
+
if (fallbackTimerId !== null) {
|
|
1845
|
+
clearTimeout(fallbackTimerId);
|
|
1846
|
+
fallbackTimerId = null;
|
|
1847
|
+
}
|
|
1848
|
+
if (pollId !== null) {
|
|
1849
|
+
clearInterval(pollId);
|
|
1850
|
+
pollId = null;
|
|
1851
|
+
}
|
|
1836
1852
|
video.muted = true;
|
|
1837
1853
|
video.play().then(() => {
|
|
1838
1854
|
video.muted = isMuted;
|
|
@@ -1840,16 +1856,33 @@ function VideoSlotInner({
|
|
|
1840
1856
|
video.muted = isMuted;
|
|
1841
1857
|
});
|
|
1842
1858
|
};
|
|
1843
|
-
if (video.readyState >= HTMLMediaElement.
|
|
1859
|
+
if (video.readyState >= HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1844
1860
|
startPlay();
|
|
1845
1861
|
} else {
|
|
1846
1862
|
onReady = startPlay;
|
|
1847
1863
|
video.addEventListener("canplay", onReady, { once: true });
|
|
1848
1864
|
video.addEventListener("loadeddata", onReady, { once: true });
|
|
1849
1865
|
video.addEventListener("playing", onReady, { once: true });
|
|
1850
|
-
if (
|
|
1866
|
+
if (isNativeHls && video.src && video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
|
1851
1867
|
video.load();
|
|
1852
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
|
+
}
|
|
1880
|
+
fallbackTimerId = window.setTimeout(() => {
|
|
1881
|
+
fallbackTimerId = null;
|
|
1882
|
+
if (onReady) {
|
|
1883
|
+
startPlay();
|
|
1884
|
+
}
|
|
1885
|
+
}, isNativeHls ? 800 : 3e3);
|
|
1853
1886
|
}
|
|
1854
1887
|
} else if (wasActiveRef.current) {
|
|
1855
1888
|
video.pause();
|
|
@@ -1865,13 +1898,25 @@ function VideoSlotInner({
|
|
|
1865
1898
|
video.removeEventListener("loadeddata", onReady);
|
|
1866
1899
|
video.removeEventListener("playing", onReady);
|
|
1867
1900
|
}
|
|
1901
|
+
if (fallbackTimerId !== null) {
|
|
1902
|
+
clearTimeout(fallbackTimerId);
|
|
1903
|
+
fallbackTimerId = null;
|
|
1904
|
+
}
|
|
1905
|
+
if (pollId !== null) {
|
|
1906
|
+
clearInterval(pollId);
|
|
1907
|
+
pollId = null;
|
|
1908
|
+
}
|
|
1868
1909
|
};
|
|
1869
1910
|
}, [isActive, isMuted, hasPlayedAhead, isNativeHls]);
|
|
1870
1911
|
useEffect(() => {
|
|
1871
1912
|
const video = videoRef.current;
|
|
1872
1913
|
if (!video) return;
|
|
1873
|
-
|
|
1874
|
-
|
|
1914
|
+
if (isActive) {
|
|
1915
|
+
video.muted = isMuted;
|
|
1916
|
+
} else {
|
|
1917
|
+
video.muted = true;
|
|
1918
|
+
}
|
|
1919
|
+
}, [isMuted, isActive]);
|
|
1875
1920
|
const [isActuallyPlaying, setIsActuallyPlaying] = useState(false);
|
|
1876
1921
|
useEffect(() => {
|
|
1877
1922
|
const video = videoRef.current;
|
|
@@ -1949,8 +1994,9 @@ function VideoSlotInner({
|
|
|
1949
1994
|
ref: videoRef,
|
|
1950
1995
|
src: mp4Src,
|
|
1951
1996
|
loop: true,
|
|
1952
|
-
muted:
|
|
1997
|
+
muted: true,
|
|
1953
1998
|
playsInline: true,
|
|
1999
|
+
autoPlay: isActive,
|
|
1954
2000
|
preload: shouldLoadSrc ? "auto" : "none",
|
|
1955
2001
|
style: {
|
|
1956
2002
|
width: "100%",
|