myetv-player 1.6.1 → 1.6.3

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.
@@ -259,7 +259,7 @@
259
259
  flex-direction: column;
260
260
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
261
261
  overflow: visible;
262
- transition: all 0.3s ease;
262
+ transition: bottom 0.3s ease, all 0.3s ease;
263
263
  }
264
264
 
265
265
  .myetv-iframe-banner.visible {
@@ -344,25 +344,30 @@
344
344
  }
345
345
 
346
346
  .myetv-iframe-banner-timer {
347
- flex: 0 0 auto;
348
- background: rgba(0, 0, 0, 0.6);
347
+ position: absolute;
348
+ bottom: -20px;
349
+ left: 50%;
350
+ transform: translateX(-50%);
351
+ background: rgba(0, 0, 0, 0.85);
349
352
  color: #fff;
350
353
  font-size: 12px;
351
- padding: 8px 12px;
354
+ padding: 6px 12px;
352
355
  text-align: center;
353
356
  font-family: Arial, sans-serif;
354
- border-top: 1px solid rgba(255, 255, 255, 0.1);
355
- border-radius: 0 0 8px 8px;
357
+ border-radius: 4px;
358
+ white-space: nowrap;
359
+ z-index: 999;
360
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
356
361
  }
357
362
 
358
363
  /* Compact button mode when space is limited */
359
364
  @media (max-width: 640px) and (max-height: 500px) {
360
365
  .myetv-iframe-banner {
361
- width: 25%; /* 1/4 of player width */
362
- min-width: 120px;
363
- max-width: 200px;
364
- left: 10px; /* Position at left */
365
- transform: translateX(0);
366
+ width: 75%; /* 3/4 of player width */
367
+ min-width: 300px;
368
+ max-width: 600px;
369
+ left: 50%; /* Center */
370
+ transform: translateX(-50%);
366
371
  border-radius: 6px;
367
372
  }
368
373
 
@@ -404,9 +409,9 @@
404
409
  /* Extra compact mode for very small screens */
405
410
  @media (max-width: 480px) and (max-height: 400px) {
406
411
  .myetv-iframe-banner {
407
- width: 30%;
408
- min-width: 100px;
409
- max-width: 150px;
412
+ width: 75%; /* 3/4 of player width */
413
+ min-width: 250px;
414
+ max-width: 500px;
410
415
  }
411
416
 
412
417
  .myetv-iframe-banner-content {
@@ -607,15 +612,112 @@
607
612
  if (this.options.debug) {
608
613
  console.log('[IframeBannerAds] Events bound');
609
614
  }
615
+
616
+ // Setup controlbar tracking
617
+ this.setupControlbarTracking();
610
618
  }
611
619
 
620
+
612
621
  /**
613
- * Update timer text display
622
+ * Setup controlbar tracking to move banner with controlbar
614
623
  */
624
+ setupControlbarTracking() {
625
+ if (!this.player || !this.player.container) {
626
+ if (this.options.debug) {
627
+ console.log('[IframeBannerAds] Cannot setup controlbar tracking');
628
+ }
629
+ return;
630
+ }
631
+
632
+ const updatePosition = () => {
633
+ requestAnimationFrame(() => this.updateBannerPosition());
634
+ };
635
+
636
+ this.controlbarObserver = new MutationObserver(() => updatePosition());
637
+ this.controlbarObserver.observe(this.player.container, {
638
+ attributes: true,
639
+ attributeFilter: ['class', 'style'],
640
+ subtree: true,
641
+ childList: false
642
+ });
643
+
644
+ let mouseTimer;
645
+ this.player.container.addEventListener('mousemove', () => {
646
+ clearTimeout(mouseTimer);
647
+ mouseTimer = setTimeout(() => updatePosition(), 50);
648
+ });
649
+
650
+ this.player.container.addEventListener('mouseleave', () => {
651
+ clearTimeout(mouseTimer);
652
+ mouseTimer = setTimeout(() => updatePosition(), 300);
653
+ });
654
+
655
+ if (this.player.addEventListener) {
656
+ this.player.addEventListener('controlsshown', () => updatePosition());
657
+ this.player.addEventListener('controlshidden', () => updatePosition());
658
+ }
659
+
660
+ setTimeout(() => updatePosition(), 100);
661
+
662
+ if (this.options.debug) {
663
+ console.log('[IframeBannerAds] Controlbar tracking setup completed');
664
+ }
665
+ }
666
+
667
+ /**
668
+ * Update banner position based on controlbar visibility
669
+ */
670
+ updateBannerPosition() {
671
+ if (!this.banner || !this.player || !this.player.container || !this.isVisible) {
672
+ return;
673
+ }
674
+
675
+ const controlbar = this.player.container.querySelector('.myetv-controls-container') ||
676
+ this.player.container.querySelector('.myetv-controls') ||
677
+ this.player.container.querySelector('[class*="controls"]');
678
+
679
+ if (!controlbar) {
680
+ if (this.options.debug) {
681
+ console.log('[IframeBannerAds] Controlbar not found');
682
+ }
683
+ this.banner.style.bottom = '10px';
684
+ return;
685
+ }
686
+
687
+ const computedStyle = window.getComputedStyle(controlbar);
688
+ const rect = controlbar.getBoundingClientRect();
689
+
690
+ const isHidden =
691
+ controlbar.classList.contains('hidden') ||
692
+ controlbar.classList.contains('myetv-controls-hidden') ||
693
+ computedStyle.opacity === '0' ||
694
+ computedStyle.visibility === 'hidden' ||
695
+ computedStyle.display === 'none' ||
696
+ rect.height === 0;
697
+
698
+ let newBottom;
699
+ if (isHidden) {
700
+ newBottom = '10px';
701
+ } else {
702
+ const controlbarHeight = controlbar.offsetHeight || rect.height || 60;
703
+ newBottom = `${controlbarHeight + 5}px`;
704
+ }
705
+
706
+ if (this.banner.style.bottom !== newBottom) {
707
+ this.banner.style.bottom = newBottom;
708
+
709
+ if (this.options.debug) {
710
+ console.log(`[IframeBannerAds] Banner repositioned to: ${newBottom} (controlbar ${isHidden ? 'hidden' : 'visible'})`);
711
+ }
712
+ }
713
+ }
714
+ /**
715
+ * Update timer text display
716
+ */
615
717
  updateTimerText() {
616
718
  if (this.timerElement) {
617
719
  if (this.countdown > 0) {
618
- this.timerElement.textContent = `Close in ${this.countdown} second${this.countdown !== 1 ? 's' : ''}`;
720
+ this.timerElement.textContent = `This ad will close in ${this.countdown} second${this.countdown !== 1 ? 's' : ''}`;
619
721
  } else {
620
722
  this.timerElement.textContent = 'Closing...';
621
723
  }
@@ -707,6 +809,9 @@
707
809
  this.isVisible = true;
708
810
  this.adShownCount++;
709
811
 
812
+ // Update banner position
813
+ setTimeout(() => this.updateBannerPosition(), 150);
814
+
710
815
  // Update last ad timestamp
711
816
  this.updateLastAdTimestamp();
712
817
 
@@ -901,6 +1006,12 @@
901
1006
  this.stopCountdown();
902
1007
  this.stopRepeatInterval();
903
1008
 
1009
+ // Cleanup controlbar tracking
1010
+ if (this.controlbarObserver) {
1011
+ this.controlbarObserver.disconnect();
1012
+ this.controlbarObserver = null;
1013
+ }
1014
+
904
1015
  // Remove DOM elements
905
1016
  if (this.banner && this.banner.parentNode) {
906
1017
  this.banner.parentNode.removeChild(this.banner);