video-ad-sdk
Version:
VAST/VPAID SDK that allows video ads to be played on top of any player
10 lines (9 loc) • 426 B
JavaScript
export const canBeShown = (icon, videoElement) => {
const currentTimeInMs = videoElement.currentTime * 1000;
const videoDurationInMs = videoElement.duration * 1000;
const offset = typeof icon.offset === 'string'
? parseInt(icon.offset, 10)
: icon.offset || 0;
const duration = icon.duration || videoDurationInMs;
return offset <= currentTimeInMs && currentTimeInMs - offset <= duration;
};