@saran-ign/video-annotation-tool
Version:
[](https://www.npmjs.com/package/@saran-ign/video-annotation-tool) [](https://www.npmjs.co
23 lines (22 loc) • 616 B
JavaScript
// @ts-nocheck
import { useRef } from 'react';
export default function usePlayer() {
const playerRef = useRef(null);
/*
* Get the current time of the video
* @returns {number} time in milliseconds
*/
const getCurrentTime = () => {
var _a;
if (playerRef.current) {
const currentTimeInMs = Math.floor(((_a = playerRef.current) === null || _a === void 0 ? void 0 : _a.currentTime) * 1000);
console.log(currentTimeInMs);
return currentTimeInMs;
}
return 0;
};
return {
playerRef,
getCurrentTime
};
}