myetv-player 1.1.1 → 1.1.2

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/src/controls.js CHANGED
@@ -368,13 +368,13 @@ createControls() {
368
368
  const controlsHTML = `
369
369
  <div class="controls" id="${controlsId}">
370
370
  <div class="progress-container">
371
- <div class="progress-bar">
372
- <div class="progress-buffer"></div>
373
- <div class="progress-filled"></div>
374
- <div class="progress-handle progress-handle-${this.options.seekHandleShape}"></div>
375
- </div>
376
- ${this.options.showSeekTooltip ? '<div class="seek-tooltip">0:00</div>' : ''}
377
- </div>
371
+ <div class="progress-bar">
372
+ <div class="progress-buffer"></div>
373
+ <div class="progress-filled"></div>
374
+ </div>
375
+ <div class="progress-handle progress-handle-${this.options.seekHandleShape}"></div> <!-- ✅ Fuori da progress-bar -->
376
+ ${this.options.showSeekTooltip ? '<div class="seek-tooltip">0:00</div>' : ''}
377
+ </div>
378
378
 
379
379
  <div class="controls-main">
380
380
  <div class="controls-left">
package/src/core.js CHANGED
@@ -70,7 +70,6 @@ constructor(videoElement, options = {}) {
70
70
  this.currentQualityIndex = 0;
71
71
  this.qualities = [];
72
72
  this.originalSources = [];
73
- this.setupMenuToggles(); // Initialize menu toggle system
74
73
  this.isPiPSupported = this.checkPiPSupport();
75
74
  this.seekTooltip = null;
76
75
  this.titleOverlay = null;
@@ -182,6 +181,7 @@ constructor(videoElement, options = {}) {
182
181
  this.interceptAutoLoading();
183
182
  this.createPlayerStructure();
184
183
  this.initializeElements();
184
+ this.setupMenuToggles(); // Initialize menu toggle system
185
185
  // audio player adaptation
186
186
  this.adaptToAudioFile = function () {
187
187
  if (this.options.audiofile) {
@@ -798,74 +798,84 @@ initializeElements() {
798
798
  this.speedMenu = this.controls?.querySelector('.speed-menu');
799
799
  this.qualityMenu = this.controls?.querySelector('.quality-menu');
800
800
  this.subtitlesMenu = this.controls?.querySelector('.subtitles-menu');
801
+ // Apply seek handle shape from options
802
+ if (this.progressHandle && this.options.seekHandleShape) {
803
+ this.setSeekHandleShape(this.options.seekHandleShape);
804
+ }
801
805
  }
802
806
 
803
807
  // Generic method to close all active menus (works with plugins too)
804
808
  closeAllMenus() {
805
- // Find all elements with class ending in '-menu' that have 'active' class
806
- const allMenus = this.controls?.querySelectorAll('[class*="-menu"].active');
807
- allMenus?.forEach(menu => {
808
- menu.classList.remove('active');
809
- });
809
+ if (!this.controls) return;
810
810
 
811
- // Remove active state from all control buttons
812
- const allButtons = this.controls?.querySelectorAll('.control-btn.active');
813
- allButtons?.forEach(btn => {
814
- btn.classList.remove('active');
815
- });
811
+ const menus = this.controls.querySelectorAll('.speed-menu, .quality-menu, .subtitles-menu, .settings-menu');
812
+ const buttons = this.controls.querySelectorAll('.control-btn');
813
+
814
+ menus.forEach(menu => menu.classList.remove('active'));
815
+ buttons.forEach(btn => btn.classList.remove('active'));
816
+
817
+ this.currentOpenMenu = null;
818
+
819
+ if (this.options.debug) {
820
+ console.log('All menus closed');
821
+ }
816
822
  }
817
823
 
818
824
  // Generic menu toggle setup (works with core menus and plugin menus)
819
825
  setupMenuToggles() {
820
- // Delegate click events to control bar for any button with associated menu
821
- if (this.controls) {
822
- this.controls.addEventListener('click', (e) => {
823
- // Find if clicked element is a control button or inside one
824
- const button = e.target.closest('.control-btn');
825
-
826
- if (!button) return;
827
-
828
- // Get button classes to find associated menu
829
- const buttonClasses = button.className.split(' ');
830
- let menuClass = null;
831
-
832
- // Find if this button has an associated menu (e.g., speed-btn -> speed-menu)
833
- for (const cls of buttonClasses) {
834
- if (cls.endsWith('-btn')) {
835
- const menuName = cls.replace('-btn', '-menu');
836
- const menu = this.controls.querySelector('.' + menuName);
837
- if (menu) {
838
- menuClass = menuName;
839
- break;
840
- }
841
- }
826
+ if (!this.controls) return;
827
+
828
+ this.currentOpenMenu = null;
829
+
830
+ this.controls.addEventListener('click', (e) => {
831
+ const button = e.target.closest('.control-btn');
832
+ if (!button) return;
833
+
834
+ const buttonClasses = Array.from(button.classList);
835
+ let menuElement = null;
836
+
837
+ for (const cls of buttonClasses) {
838
+ if (cls.endsWith('-btn')) {
839
+ const menuClass = cls.replace('-btn', '-menu');
840
+ menuElement = this.controls.querySelector(`.${menuClass}`);
841
+ if (menuElement) break;
842
842
  }
843
+ }
843
844
 
844
- if (!menuClass) return;
845
+ if (!menuElement) return;
845
846
 
846
- e.stopPropagation();
847
+ e.stopPropagation();
848
+ e.preventDefault();
847
849
 
848
- // Get the menu element
849
- const menu = this.controls.querySelector('.' + menuClass);
850
- const isOpen = menu.classList.contains('active');
850
+ const isOpen = menuElement.classList.contains('active');
851
851
 
852
- // Close all menus first
853
- this.closeAllMenus();
852
+ this.closeAllMenus();
854
853
 
855
- // If menu was closed, open it
856
- if (!isOpen) {
857
- menu.classList.add('active');
858
- button.classList.add('active');
854
+ if (!isOpen) {
855
+ menuElement.classList.add('active');
856
+ button.classList.add('active');
857
+ this.currentOpenMenu = menuElement;
858
+ if (this.options.debug) {
859
+ console.log('Menu opened:', menuElement.className);
859
860
  }
860
- });
861
- }
861
+ } else {
862
+ this.currentOpenMenu = null;
863
+ if (this.options.debug) {
864
+ console.log('Menu closed:', menuElement.className);
865
+ }
866
+ }
867
+ });
862
868
 
863
- // Close menus when clicking outside controls
864
869
  document.addEventListener('click', (e) => {
865
- if (!this.controls?.contains(e.target)) {
870
+ if (!this.controls) return;
871
+ if (!this.controls.contains(e.target)) {
866
872
  this.closeAllMenus();
867
873
  }
868
874
  });
875
+
876
+ if (this.options.debug) {
877
+ console.log('✅ Menu toggle system initialized (click-based, auto-close)');
878
+ }
869
879
  }
870
880
 
871
881
  updateVolumeSliderVisual() {
@@ -1176,9 +1186,11 @@ updateBuffer() {
1176
1186
  }
1177
1187
 
1178
1188
  startSeeking(e) {
1189
+ if (e.cancelable) e.preventDefault();
1179
1190
  if (this.isChangingQuality) return;
1180
1191
 
1181
1192
  this.isUserSeeking = true;
1193
+ this.progressContainer.classList.add('seeking');
1182
1194
  this.seek(e);
1183
1195
  e.preventDefault();
1184
1196
 
@@ -1190,6 +1202,7 @@ startSeeking(e) {
1190
1202
  }
1191
1203
 
1192
1204
  continueSeeking(e) {
1205
+ if (e.cancelable) e.preventDefault();
1193
1206
  if (this.isUserSeeking && !this.isChangingQuality) {
1194
1207
  this.seek(e);
1195
1208
  }
@@ -1197,9 +1210,13 @@ continueSeeking(e) {
1197
1210
 
1198
1211
  endSeeking() {
1199
1212
  this.isUserSeeking = false;
1213
+ this.progressContainer.classList.remove('seeking');
1200
1214
  }
1201
1215
 
1202
1216
  seek(e) {
1217
+ if (e.cancelable) {
1218
+ e.preventDefault();
1219
+ }
1203
1220
  if (!this.video || !this.progressContainer || !this.progressFilled || !this.progressHandle || this.isChangingQuality) return;
1204
1221
 
1205
1222
  const rect = this.progressContainer.getBoundingClientRect();
@@ -1620,7 +1637,7 @@ bindPosterEvents() {
1620
1637
  // Hide poster when video is loading/playing
1621
1638
  this.video.addEventListener('playing', () => {
1622
1639
  this.hidePoster();
1623
- });
1640
+ });
1624
1641
 
1625
1642
  // Show poster on load if not autoplay
1626
1643
  if (!this.options.autoplay) {
package/src/events.js CHANGED
@@ -170,6 +170,7 @@
170
170
  // Playback events
171
171
  this.video.addEventListener('playing', () => {
172
172
  this.hideLoading();
173
+ this.closeAllMenus();
173
174
  // Trigger playing event - video is now actually playing
174
175
  this.triggerEvent('playing', {
175
176
  currentTime: this.getCurrentTime(),
@@ -394,6 +395,10 @@
394
395
  // Mouse events (desktop)
395
396
  this.progressContainer.addEventListener('click', (e) => this.seek(e));
396
397
  this.progressContainer.addEventListener('mousedown', (e) => this.startSeeking(e));
398
+ if (this.progressHandle) {
399
+ this.progressHandle.addEventListener('mousedown', this.startSeeking.bind(this));
400
+ this.progressHandle.addEventListener('touchstart', this.startSeeking.bind(this), { passive: false });
401
+ }
397
402
 
398
403
  // Touch events (mobile)
399
404
  this.progressContainer.addEventListener('touchstart', (e) => {
package/src/subtitles.js CHANGED
@@ -343,11 +343,11 @@ updateSubtitlesButton() {
343
343
  var subtitlesBtn = this.controls && this.controls.querySelector('.subtitles-btn');
344
344
  if (!subtitlesBtn) return;
345
345
 
346
+ subtitlesBtn.classList.remove('active');
347
+
346
348
  if (this.subtitlesEnabled) {
347
- subtitlesBtn.classList.add('active');
348
349
  subtitlesBtn.title = this.t('subtitlesdisable');
349
350
  } else {
350
- subtitlesBtn.classList.remove('active');
351
351
  subtitlesBtn.title = this.t('subtitlesenable');
352
352
  }
353
353
  }
@@ -383,14 +383,6 @@ updateSubtitlesUI() {
383
383
  bindSubtitleEvents() {
384
384
  var self = this;
385
385
 
386
- var subtitlesBtn = this.controls && this.controls.querySelector('.subtitles-btn');
387
- if (subtitlesBtn) {
388
- subtitlesBtn.addEventListener('click', function (e) {
389
- e.stopPropagation();
390
- self.toggleSubtitles();
391
- });
392
- }
393
-
394
386
  var subtitlesMenu = this.controls && this.controls.querySelector('.subtitles-menu');
395
387
  if (subtitlesMenu) {
396
388
  subtitlesMenu.addEventListener('click', function (e) {
@@ -399,6 +391,7 @@ bindSubtitleEvents() {
399
391
  }
400
392
  }
401
393
 
394
+
402
395
  handleSubtitlesMenuClick(e) {
403
396
  if (!e.target.classList.contains('subtitles-option')) return;
404
397