useAfterTimestamp
useAfterTimestmp
returns boolean that represents whether specified timestamp already passed.
For offline processing, you can’t rely on real time clock to measure time. This hook replaces patterns
where you would use useEffect
+ setTimeout
in a live processing case.
Reference
import { Text, View, useAfterTimestamp } from "@swmansion/smelter";import { OfflineSmelter } from "@swmansion/smelter-node";
function ExampleApp() { const afterTimestamp = useAfterTimestamp(5000); return ( <View> {afterTimestamp ? ( <Text>After 5 second timestamp</Text> ) : ( <Text>Before 5 second timestamp</Text> )} </View> );}
async function run() { const smelter = new OfflineSmelter(); await smelter.init(); await smelter.render(<ExampleApp />, {18 collapsed lines
type: "mp4", serverPath: "./output.mp4", video: { encoder: { type: "ffmpeg_h264", preset: "ultrafast", }, resolution: { width: 1920, height: 1080, }, }, audio: { encoder: { type: "aac", channels: "stereo", }, }, });}void run();
function useAfterTimestamp(timestampMs: number): boolean
Arguments
timestampMs
Timestamp in milliseconds.
- Type:
number
Returns
true
if the time defined by the timestamp already passed, false
otherwise.
- Type:
boolean