Skip to content

Commit

Permalink
Fix 6321
Browse files Browse the repository at this point in the history
  • Loading branch information
ojadhav-onshape committed Oct 15, 2023
1 parent 5e3012a commit 72fc9cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
18 changes: 15 additions & 3 deletions src/Common/hooks/useHLSPlayer.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/Consultations/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const Feed: React.FC<IFeedProps> = ({ 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<HTMLVideoElement | ReactPlayer | null>(null);

Expand Down Expand Up @@ -465,7 +465,7 @@ export const Feed: React.FC<IFeedProps> = ({ consultationId, facilityId }) => {
{isIOS ? (
<ReactPlayer
url={url}
ref={liveFeedPlayerRef.current as any}
ref={liveFeedPlayerRef as any}
controls={false}
playsinline={true}
playing={true}
Expand Down

0 comments on commit 72fc9cb

Please sign in to comment.