diff --git a/src/Common/hooks/useHLSPlayer.ts b/src/Common/hooks/useHLSPlayer.ts index 32a52043fe7..eea0cc72002 100644 --- a/src/Common/hooks/useHLSPlayer.ts +++ b/src/Common/hooks/useHLSPlayer.ts @@ -1,13 +1,25 @@ import ReactPlayer from "react-player"; import { IOptions } from "./useMSEplayer"; -export const useHLSPLayer = (ref: ReactPlayer | null) => { +export const useHLSPLayer = (ref: any) => { const startStream = ({ onSuccess, onError }: IOptions = {}) => { + const videoEle = ref.player.player.player; + try { - ref?.setState({ url: ref?.props.url + "&t=" + Date.now() }); - onSuccess && onSuccess(undefined); + const player = ref as ReactPlayer; + + videoEle.addEventListener("playing", onSuccess); + videoEle.addEventListener("error", onError); + + player.seekTo(player.getDuration()); } catch (err) { onError && onError(err); + } finally { + // eslint-disable-next-line no-unsafe-finally + return () => { + videoEle.removeEventListener("playing", onSuccess); + videoEle.removeEventListener("error", onError); + }; } }; return { diff --git a/src/Components/Facility/Consultations/Feed.tsx b/src/Components/Facility/Consultations/Feed.tsx index 31691c736f4..425dc96899e 100644 --- a/src/Components/Facility/Consultations/Feed.tsx +++ b/src/Components/Facility/Consultations/Feed.tsx @@ -93,7 +93,7 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => { return () => clearTimeout(timeout); }, [cameraState]); - const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent); + const isIOS = true; ///iPad|iPhone|iPod/.test(navigator.userAgent); const liveFeedPlayerRef = useRef(null); @@ -465,7 +465,7 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => { {isIOS ? (