Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,13 @@ export default defineComponent({
locale: props.locale,
};

try {
// Use a timeout to ensure the element is in the DOM.
setTimeout(() => {
try {
if (containerRef.value) {
const player = new IVLabsPlayer(`#${uniqueId}`, playerConfig);
playerRef.value = player;
setTimeout(() => {
try {
if (containerRef.value) {
const player = new IVLabsPlayer(`#${uniqueId}`, playerConfig);
playerRef.value = player;

// Register event listeners if onAnalyticsEvent is provided.
}
} catch (error) {
console.error('Error initializing IVLabsPlayer:', error);
}
}, 0);
// Register event listeners if onAnalyticsEvent is provided.
if (props.onAnalyticsEvent) {
player.on('PLAYER_LOADED', (payload?: AnalyticsPayload) => (props.onAnalyticsEvent as Function)('PLAYER_LOADED', payload));
player.on('VIDEO_STARTED', (payload?: AnalyticsPayload) => (props.onAnalyticsEvent as Function)('VIDEO_STARTED', payload));
Expand All @@ -121,10 +114,10 @@ setTimeout(() => {
player.loadTranslations(props.locale, props.translations);
}
}
}, 0);
} catch (error) {
console.error('Error initializing IVLabsPlayer:', error);
}
} catch (error) {
console.error('Error initializing IVLabsPlayer:', error);
}
}, 0);
}
});

Expand Down