myetv-player 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -1
- package/dist/myetv-player.js +469 -20
- package/dist/myetv-player.min.js +427 -8
- package/package.json +3 -2
- package/plugins/google-adsense-ads/README.md +230 -0
- package/plugins/google-adsense-ads/g-adsense-ads-plugin.js +75 -8
- package/plugins/google-ima-ads/README.md +258 -0
- package/plugins/google-ima-ads/g-ima-ads-plugin.js +2 -2
- package/plugins/youtube/myetv-player-youtube-plugin.js +72 -39
|
@@ -3434,11 +3434,67 @@
|
|
|
3434
3434
|
'3': 'BUFFERING',
|
|
3435
3435
|
'5': 'CUED'
|
|
3436
3436
|
};
|
|
3437
|
-
if (this.api.player.options.debug) console.log('[YT Plugin] State:', states[event.data], event.data);
|
|
3438
3437
|
|
|
3439
|
-
|
|
3438
|
+
if (this.api.player.options.debug)
|
|
3439
|
+
console.log('YT Plugin State:', states[event.data], event.data);
|
|
3440
|
+
|
|
3441
|
+
// Handle auto-hide based on YouTube state
|
|
3442
|
+
if (event.data === YT.PlayerState.PAUSED) {
|
|
3443
|
+
// Video paused: show controls and CANCEL timer
|
|
3444
|
+
if (this.api.player.showControlsNow) {
|
|
3445
|
+
this.api.player.showControlsNow();
|
|
3446
|
+
}
|
|
3447
|
+
// Clear timer to prevent controls from disappearing
|
|
3448
|
+
if (this.api.player.autoHideTimer) {
|
|
3449
|
+
clearTimeout(this.api.player.autoHideTimer);
|
|
3450
|
+
this.api.player.autoHideTimer = null;
|
|
3451
|
+
}
|
|
3452
|
+
// Add CSS class
|
|
3453
|
+
if (this.api.container) {
|
|
3454
|
+
this.api.container.classList.add('video-paused');
|
|
3455
|
+
}
|
|
3456
|
+
|
|
3457
|
+
if (this.api.player.options.debug)
|
|
3458
|
+
console.log('YT Plugin: Video paused - controls locked visible');
|
|
3459
|
+
}
|
|
3460
|
+
|
|
3461
|
+
if (event.data === YT.PlayerState.PLAYING) {
|
|
3462
|
+
// Video playing: remove class and restart auto-hide
|
|
3463
|
+
if (this.api.container) {
|
|
3464
|
+
this.api.container.classList.remove('video-paused');
|
|
3465
|
+
}
|
|
3466
|
+
// Restart auto-hide only if enabled
|
|
3467
|
+
if (this.api.player.options.autoHide && this.api.player.autoHideInitialized) {
|
|
3468
|
+
if (this.api.player.showControlsNow) {
|
|
3469
|
+
this.api.player.showControlsNow();
|
|
3470
|
+
}
|
|
3471
|
+
if (this.api.player.resetAutoHideTimer) {
|
|
3472
|
+
this.api.player.resetAutoHideTimer();
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
if (this.api.player.options.debug)
|
|
3477
|
+
console.log('YT Plugin: Video playing - auto-hide restarted');
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3480
|
+
// Handle when video fails to autoplay (stays in UNSTARTED)
|
|
3481
|
+
if (event.data === YT.PlayerState.UNSTARTED || event.data === -1) {
|
|
3482
|
+
// Show controls and block auto-hide
|
|
3483
|
+
if (this.api.player.showControlsNow) {
|
|
3484
|
+
this.api.player.showControlsNow();
|
|
3485
|
+
}
|
|
3486
|
+
// Clear any active timer
|
|
3487
|
+
if (this.api.player.autoHideTimer) {
|
|
3488
|
+
clearTimeout(this.api.player.autoHideTimer);
|
|
3489
|
+
this.api.player.autoHideTimer = null;
|
|
3490
|
+
}
|
|
3491
|
+
|
|
3492
|
+
if (this.api.player.options.debug)
|
|
3493
|
+
console.log('YT Plugin: Video UNSTARTED (autoplay blocked?) - controls locked visible');
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
// Start timeout when video is unstarted
|
|
3440
3497
|
if (event.data === YT.PlayerState.UNSTARTED || event.data === -1) {
|
|
3441
|
-
// start timeout when video is unstarted
|
|
3442
3498
|
if (this.playAttemptTimeout) {
|
|
3443
3499
|
clearTimeout(this.playAttemptTimeout);
|
|
3444
3500
|
}
|
|
@@ -3448,15 +3504,14 @@
|
|
|
3448
3504
|
|
|
3449
3505
|
const currentState = this.ytPlayer.getPlayerState();
|
|
3450
3506
|
|
|
3451
|
-
// If video is
|
|
3507
|
+
// If video is unstarted after timeout, consider it restricted
|
|
3452
3508
|
if (currentState === YT.PlayerState.UNSTARTED || currentState === -1) {
|
|
3453
|
-
if (this.api.player.options.debug)
|
|
3509
|
+
if (this.api.player.options.debug)
|
|
3454
3510
|
console.log('YT Plugin: Video stuck in UNSTARTED - possibly members-only or restricted');
|
|
3455
|
-
}
|
|
3456
3511
|
|
|
3457
3512
|
// Trigger ended event
|
|
3458
3513
|
this.api.triggerEvent('ended', {
|
|
3459
|
-
reason: '
|
|
3514
|
+
reason: 'videorestrictedormembership',
|
|
3460
3515
|
state: currentState
|
|
3461
3516
|
});
|
|
3462
3517
|
|
|
@@ -3464,14 +3519,12 @@
|
|
|
3464
3519
|
this.showPosterOverlay();
|
|
3465
3520
|
|
|
3466
3521
|
// Trigger custom event
|
|
3467
|
-
this.api.triggerEvent('
|
|
3522
|
+
this.api.triggerEvent('youtubepluginmembershiprestricted', {
|
|
3468
3523
|
videoId: this.videoId
|
|
3469
3524
|
});
|
|
3470
3525
|
}
|
|
3471
|
-
}, 15000); // 15 seconds
|
|
3472
|
-
|
|
3473
|
-
} else if (event.data === YT.PlayerState.PLAYING ||
|
|
3474
|
-
event.data === YT.PlayerState.BUFFERING) {
|
|
3526
|
+
}, 15000); // 15 seconds timeout
|
|
3527
|
+
} else if (event.data === YT.PlayerState.PLAYING || event.data === YT.PlayerState.BUFFERING) {
|
|
3475
3528
|
// Clear the timeout if video starts correctly
|
|
3476
3529
|
if (this.playAttemptTimeout) {
|
|
3477
3530
|
clearTimeout(this.playAttemptTimeout);
|
|
@@ -3488,9 +3541,8 @@
|
|
|
3488
3541
|
|
|
3489
3542
|
// Handle live stream ended
|
|
3490
3543
|
if (this.isLiveStream && event.data === YT.PlayerState.ENDED) {
|
|
3491
|
-
if (this.api.player.options.debug)
|
|
3492
|
-
console.log('
|
|
3493
|
-
}
|
|
3544
|
+
if (this.api.player.options.debug)
|
|
3545
|
+
console.log('YT Plugin: Live stream ended (player state ENDED)');
|
|
3494
3546
|
this.handleLiveStreamEnded();
|
|
3495
3547
|
return;
|
|
3496
3548
|
}
|
|
@@ -3500,24 +3552,19 @@
|
|
|
3500
3552
|
if (event.data === YT.PlayerState.PAUSED) {
|
|
3501
3553
|
// Orange when paused during live
|
|
3502
3554
|
badge.style.background = '#ff8800';
|
|
3503
|
-
badge.textContent = '
|
|
3555
|
+
badge.textContent = 'LIVE';
|
|
3504
3556
|
badge.title = 'Livestreaming in Pause';
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
console.log('[YT Plugin] 🟠 Live paused');
|
|
3508
|
-
}
|
|
3557
|
+
if (this.api.player.options.debug)
|
|
3558
|
+
console.log('YT Plugin: Live paused');
|
|
3509
3559
|
} else if (event.data === YT.PlayerState.PLAYING) {
|
|
3510
3560
|
// Red when playing (will be checked for de-sync below)
|
|
3511
3561
|
badge.style.background = '#ff0000';
|
|
3512
3562
|
badge.textContent = 'LIVE';
|
|
3513
3563
|
badge.title = 'Livestreaming';
|
|
3514
|
-
|
|
3515
|
-
if (this.api.player.options.debug) {
|
|
3516
|
-
console.log('[YT Plugin] 🔴 Live playing');
|
|
3517
|
-
}
|
|
3518
3564
|
}
|
|
3519
3565
|
}
|
|
3520
3566
|
|
|
3567
|
+
// Handle state changes
|
|
3521
3568
|
switch (event.data) {
|
|
3522
3569
|
case YT.PlayerState.PLAYING:
|
|
3523
3570
|
this.api.triggerEvent('played', {});
|
|
@@ -3549,27 +3596,13 @@
|
|
|
3549
3596
|
case YT.PlayerState.ENDED:
|
|
3550
3597
|
this.api.triggerEvent('ended', {});
|
|
3551
3598
|
|
|
3552
|
-
// Show play icon
|
|
3599
|
+
// Show play icon for replay
|
|
3553
3600
|
if (playIcon && pauseIcon) {
|
|
3554
3601
|
playIcon.classList.remove('hidden');
|
|
3555
3602
|
pauseIcon.classList.add('hidden');
|
|
3556
3603
|
}
|
|
3557
3604
|
break;
|
|
3558
3605
|
}
|
|
3559
|
-
|
|
3560
|
-
if (event.data === YT.PlayerState.PAUSED) {
|
|
3561
|
-
// add pause class
|
|
3562
|
-
if (this.api.container) {
|
|
3563
|
-
this.api.container.classList.add('video-paused');
|
|
3564
|
-
}
|
|
3565
|
-
}
|
|
3566
|
-
|
|
3567
|
-
if (event.data === YT.PlayerState.PLAYING) {
|
|
3568
|
-
// remove pause class
|
|
3569
|
-
if (this.api.container) {
|
|
3570
|
-
this.api.container.classList.remove('video-paused');
|
|
3571
|
-
}
|
|
3572
|
-
}
|
|
3573
3606
|
}
|
|
3574
3607
|
|
|
3575
3608
|
onPlaybackQualityChange(event) {
|