Skip to content

Commit

Permalink
poll for presence of JHMTApi
Browse files Browse the repository at this point in the history
  • Loading branch information
wjoosen committed Jul 15, 2024
1 parent 6caff93 commit 64e9477
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions adscript/src/integration/AdScriptConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ export class AdScriptConnector {
* @returns
*/
constructor(player: ChromelessPlayer, configuration: AdScriptConfiguration, metadata: MainVideoContentMetadata) {
if (!window.JHMTApi || !window.JHMT) {
console.error('JHMT API not found, make sure you included the script to initialize AdScript Measurement')
return;
}
this.adscriptIntegration = new AdScriptTHEOIntegration(player, configuration, metadata)
const interval = window.setInterval(() => {
if (typeof window.JHMTApi === 'object') {
window.clearInterval(interval);
this.adscriptIntegration = new AdScriptTHEOIntegration(player, configuration, metadata)

}
}, 20)
window.setTimeout(() => {
if (!window.JHMTApi) {
window.clearInterval(interval)
console.error('JHMT API not found, make sure you included the script to initialize AdScript Measurement')
return;
}
}, 5000)
}

updateMetadata(metadata: any): void {
Expand Down

0 comments on commit 64e9477

Please sign in to comment.