video-ad-sdk
Version:
VAST/VPAID SDK that allows video ads to be played on top of any player
14 lines (13 loc) • 648 B
JavaScript
import { getInteractiveFiles } from '../../../vastSelectors';
import { isSupported } from './isSupported';
export const loadCreative = async (vastChain, videoAdContainer) => {
const interactiveFiles = (vastChain[0].ad && getInteractiveFiles(vastChain[0].ad)) || [];
const creative = interactiveFiles.find(isSupported);
if (!creative || !creative.src) {
throw new TypeError('VastChain does not contain a supported vpaid creative');
}
const { src: source, type } = creative;
await videoAdContainer.addScript(source, { type });
const context = videoAdContainer.executionContext;
return context.getVPAIDAd();
};