Skip to content

Commit

Permalink
fix required params
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellov7 committed Aug 25, 2024
1 parent 0a1b358 commit 892faec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@teyuto/teyuto-player-analytics",
"author": "Teyuto",
"license": "MIT",
"version": "1.0.1",
"version": "1.0.3",
"description": " Teyuto Player Analytics SDK enables easy integration of analytics tracking for video playback using various popular players including Video.js, HLS.js, Plyr, and Shaka Player.",
"repository": {
"type": "git",
Expand Down
12 changes: 9 additions & 3 deletions src/TeyutoPlayerAnalytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
}

init(player, videoId) {
if (!player) {
throw new Error('Player is required');
}
if (!videoId) {
throw new Error('Video ID is required');
}
this.player = player;
this.videoId = videoId;
this.attachEventListeners();
Expand Down Expand Up @@ -235,20 +241,20 @@
}

attachEventListeners() {
console.log('Attempting to attach Shaka Player event listeners');
// console.log('Attempting to attach Shaka Player event listeners');
this.tryAttachListeners();
}

tryAttachListeners() {
const videoElement = this.player.getMediaElement();
if (videoElement) {
console.log('Video element found, attaching listeners');
// console.log('Video element found, attaching listeners');
this.attachListenersToVideo(videoElement);
if (this.retryInterval) {
clearInterval(this.retryInterval);
}
} else {
console.log('Video element not found, will retry');
// console.log('Video element not found, will retry');
if (!this.retryInterval) {
this.retryInterval = setInterval(() => {
this.retryCount++;
Expand Down

0 comments on commit 892faec

Please sign in to comment.