unified-video-framework 1.4.204 → 1.4.206
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.
|
@@ -384,9 +384,6 @@ export class WebPlayer extends BasePlayer {
|
|
|
384
384
|
this.state.isPlaying = true;
|
|
385
385
|
this.state.isPaused = false;
|
|
386
386
|
this.emit('onPlay');
|
|
387
|
-
|
|
388
|
-
// Hide play overlay when playback starts
|
|
389
|
-
this.hidePlayOverlay();
|
|
390
387
|
});
|
|
391
388
|
|
|
392
389
|
this.video.addEventListener('playing', () => {
|
|
@@ -396,9 +393,6 @@ export class WebPlayer extends BasePlayer {
|
|
|
396
393
|
try { this.video?.pause(); } catch (_) {}
|
|
397
394
|
}
|
|
398
395
|
|
|
399
|
-
// Also hide overlay on playing event (more reliable)
|
|
400
|
-
this.hidePlayOverlay();
|
|
401
|
-
|
|
402
396
|
// Stop buffering state
|
|
403
397
|
this.setBuffering(false);
|
|
404
398
|
});
|
|
@@ -436,6 +430,7 @@ export class WebPlayer extends BasePlayer {
|
|
|
436
430
|
});
|
|
437
431
|
|
|
438
432
|
this.video.addEventListener('canplay', () => {
|
|
433
|
+
this.debugLog('📡 canplay event fired');
|
|
439
434
|
this.setBuffering(false);
|
|
440
435
|
this.emit('onReady');
|
|
441
436
|
|
|
@@ -449,21 +444,23 @@ export class WebPlayer extends BasePlayer {
|
|
|
449
444
|
}
|
|
450
445
|
|
|
451
446
|
// Attempt autoplay once when video is ready to play
|
|
447
|
+
this.debugLog(`🎬 Autoplay check: config.autoPlay=${this.config.autoPlay}, autoplayAttempted=${this.autoplayAttempted}`);
|
|
452
448
|
if (this.config.autoPlay && !this.autoplayAttempted) {
|
|
449
|
+
this.debugLog('🎬 Starting intelligent autoplay attempt');
|
|
453
450
|
this.autoplayAttempted = true;
|
|
454
451
|
this.attemptIntelligentAutoplay().then(success => {
|
|
455
452
|
if (!success) {
|
|
456
|
-
this.debugWarn('❌ Intelligent autoplay failed
|
|
457
|
-
this.showPlayOverlay();
|
|
453
|
+
this.debugWarn('❌ Intelligent autoplay failed - will retry on user interaction');
|
|
458
454
|
this.setupAutoplayRetry();
|
|
459
455
|
} else {
|
|
460
456
|
this.debugLog('✅ Intelligent autoplay succeeded');
|
|
461
457
|
}
|
|
462
458
|
}).catch(error => {
|
|
463
459
|
this.debugError('Autoplay failed:', error);
|
|
464
|
-
this.showPlayOverlay();
|
|
465
460
|
this.setupAutoplayRetry();
|
|
466
461
|
});
|
|
462
|
+
} else {
|
|
463
|
+
this.debugLog(`⛔ Skipping autoplay: autoPlay=${this.config.autoPlay}, attempted=${this.autoplayAttempted}`);
|
|
467
464
|
}
|
|
468
465
|
});
|
|
469
466
|
|
|
@@ -912,13 +909,20 @@ export class WebPlayer extends BasePlayer {
|
|
|
912
909
|
* Attempt intelligent autoplay based on detected capabilities
|
|
913
910
|
*/
|
|
914
911
|
private async attemptIntelligentAutoplay(): Promise<boolean> {
|
|
915
|
-
|
|
912
|
+
this.debugLog('🎬 attemptIntelligentAutoplay called');
|
|
913
|
+
if (!this.config.autoPlay || !this.video) {
|
|
914
|
+
this.debugLog(`⛔ Early return: autoPlay=${this.config.autoPlay}, video=${!!this.video}`);
|
|
915
|
+
return false;
|
|
916
|
+
}
|
|
916
917
|
|
|
917
918
|
// Detect capabilities first
|
|
919
|
+
this.debugLog('🔍 Detecting autoplay capabilities...');
|
|
918
920
|
await this.detectAutoplayCapabilities();
|
|
921
|
+
this.debugLog(`📦 Capabilities detected: canAutoplayMuted=${this.autoplayCapabilities.canAutoplayMuted}, canAutoplayUnmuted=${this.autoplayCapabilities.canAutoplayUnmuted}`);
|
|
919
922
|
|
|
920
923
|
// Check if user has activated the page (navigation counts as activation)
|
|
921
924
|
const hasActivation = this.hasUserActivation();
|
|
925
|
+
this.debugLog(`👤 User activation: ${hasActivation}`);
|
|
922
926
|
|
|
923
927
|
// Try unmuted autoplay if:
|
|
924
928
|
// 1. Browser supports unmuted autoplay OR user has activated the page
|
|
@@ -932,8 +936,10 @@ export class WebPlayer extends BasePlayer {
|
|
|
932
936
|
this.debugLog(`🔊 Attempting unmuted autoplay (activation: ${hasActivation})`);
|
|
933
937
|
|
|
934
938
|
try {
|
|
939
|
+
this.debugLog('▶️ Calling play() for unmuted autoplay...');
|
|
935
940
|
await this.play();
|
|
936
941
|
// Verify video is actually playing
|
|
942
|
+
this.debugLog(`📊 Play returned, video.paused=${this.video.paused}`);
|
|
937
943
|
if (!this.video.paused) {
|
|
938
944
|
this.debugLog('✅ Unmuted autoplay successful');
|
|
939
945
|
return true;
|
|
@@ -941,7 +947,7 @@ export class WebPlayer extends BasePlayer {
|
|
|
941
947
|
this.debugLog('⚠️ Unmuted play() succeeded but video is paused, trying muted');
|
|
942
948
|
}
|
|
943
949
|
} catch (error) {
|
|
944
|
-
this.debugLog('⚠️ Unmuted autoplay failed,
|
|
950
|
+
this.debugLog('⚠️ Unmuted autoplay failed:', error);
|
|
945
951
|
}
|
|
946
952
|
}
|
|
947
953
|
|
|
@@ -951,8 +957,10 @@ export class WebPlayer extends BasePlayer {
|
|
|
951
957
|
this.debugLog('🔇 Attempting muted autoplay');
|
|
952
958
|
|
|
953
959
|
try {
|
|
960
|
+
this.debugLog('▶️ Calling play() for muted autoplay...');
|
|
954
961
|
await this.play();
|
|
955
962
|
// Verify video is actually playing
|
|
963
|
+
this.debugLog(`📊 Play returned, video.paused=${this.video.paused}`);
|
|
956
964
|
if (!this.video.paused) {
|
|
957
965
|
this.debugLog('✅ Muted autoplay successful');
|
|
958
966
|
// Show YouTube-style unmute button instead of blocking overlay
|
|
@@ -962,7 +970,7 @@ export class WebPlayer extends BasePlayer {
|
|
|
962
970
|
this.debugLog('❌ Muted play() succeeded but video is paused');
|
|
963
971
|
}
|
|
964
972
|
} catch (error) {
|
|
965
|
-
this.debugLog('❌ Muted autoplay failed');
|
|
973
|
+
this.debugLog('❌ Muted autoplay failed:', error);
|
|
966
974
|
}
|
|
967
975
|
}
|
|
968
976
|
|
|
@@ -1013,160 +1021,6 @@ export class WebPlayer extends BasePlayer {
|
|
|
1013
1021
|
this.debugLog('🎯 Autoplay retry armed - waiting for user interaction');
|
|
1014
1022
|
}
|
|
1015
1023
|
|
|
1016
|
-
private showPlayOverlay(): void {
|
|
1017
|
-
// Don't show overlay if unmute button is already visible (video is autoplaying muted)
|
|
1018
|
-
const unmuteBtn = document.getElementById('uvf-unmute-btn');
|
|
1019
|
-
if (unmuteBtn) {
|
|
1020
|
-
this.debugLog('Skipping play overlay - video is autoplaying muted with unmute button');
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
// Don't show overlay if video is already playing
|
|
1025
|
-
if (this.video && !this.video.paused) {
|
|
1026
|
-
this.debugLog('Skipping play overlay - video is already playing');
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
// Remove existing overlay
|
|
1031
|
-
this.hidePlayOverlay();
|
|
1032
|
-
|
|
1033
|
-
this.debugLog('📺 Showing play overlay due to autoplay restriction');
|
|
1034
|
-
|
|
1035
|
-
const overlay = document.createElement('div');
|
|
1036
|
-
overlay.id = 'uvf-play-overlay';
|
|
1037
|
-
overlay.className = 'uvf-play-overlay';
|
|
1038
|
-
|
|
1039
|
-
const playButton = document.createElement('button');
|
|
1040
|
-
playButton.className = 'uvf-play-button';
|
|
1041
|
-
playButton.setAttribute('aria-label', 'Play video');
|
|
1042
|
-
playButton.innerHTML = `
|
|
1043
|
-
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
1044
|
-
<path d="M8 5v14l11-7z"/>
|
|
1045
|
-
</svg>
|
|
1046
|
-
`;
|
|
1047
|
-
|
|
1048
|
-
const message = document.createElement('div');
|
|
1049
|
-
message.className = 'uvf-play-message';
|
|
1050
|
-
message.textContent = 'Click to play';
|
|
1051
|
-
|
|
1052
|
-
overlay.appendChild(playButton);
|
|
1053
|
-
overlay.appendChild(message);
|
|
1054
|
-
|
|
1055
|
-
// Enhanced click handler with better error handling
|
|
1056
|
-
const handlePlayClick = async (e: Event) => {
|
|
1057
|
-
e.preventDefault();
|
|
1058
|
-
e.stopPropagation();
|
|
1059
|
-
this.lastUserInteraction = Date.now();
|
|
1060
|
-
this.debugLog('▶️ User clicked play overlay');
|
|
1061
|
-
|
|
1062
|
-
try {
|
|
1063
|
-
// Ensure video is ready
|
|
1064
|
-
if (!this.video) {
|
|
1065
|
-
this.debugError('Video element not available');
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
// Try to play
|
|
1070
|
-
await this.play();
|
|
1071
|
-
this.debugLog('✅ Play successful after user click');
|
|
1072
|
-
} catch (error) {
|
|
1073
|
-
this.debugError('❌ Failed to play after user interaction:', error);
|
|
1074
|
-
// Show error message on overlay
|
|
1075
|
-
message.textContent = 'Unable to play. Please try again.';
|
|
1076
|
-
message.style.color = '#ff6b6b';
|
|
1077
|
-
}
|
|
1078
|
-
};
|
|
1079
|
-
|
|
1080
|
-
// Add click handler to button
|
|
1081
|
-
playButton.addEventListener('click', handlePlayClick);
|
|
1082
|
-
|
|
1083
|
-
// Also allow clicking anywhere on overlay
|
|
1084
|
-
overlay.addEventListener('click', async (e) => {
|
|
1085
|
-
if (e.target === overlay) {
|
|
1086
|
-
await handlePlayClick(e);
|
|
1087
|
-
}
|
|
1088
|
-
});
|
|
1089
|
-
|
|
1090
|
-
// Add enhanced styles with better visibility
|
|
1091
|
-
const style = document.createElement('style');
|
|
1092
|
-
style.textContent = `
|
|
1093
|
-
.uvf-play-overlay {
|
|
1094
|
-
position: absolute !important;
|
|
1095
|
-
top: 0 !important;
|
|
1096
|
-
left: 0 !important;
|
|
1097
|
-
width: 100% !important;
|
|
1098
|
-
height: 100% !important;
|
|
1099
|
-
background: rgba(0, 0, 0, 0.85) !important;
|
|
1100
|
-
display: flex !important;
|
|
1101
|
-
flex-direction: column !important;
|
|
1102
|
-
justify-content: center !important;
|
|
1103
|
-
align-items: center !important;
|
|
1104
|
-
z-index: 999999 !important;
|
|
1105
|
-
cursor: pointer !important;
|
|
1106
|
-
backdrop-filter: blur(4px);
|
|
1107
|
-
-webkit-backdrop-filter: blur(4px);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
.uvf-play-button {
|
|
1111
|
-
width: 96px !important;
|
|
1112
|
-
height: 96px !important;
|
|
1113
|
-
border-radius: 50% !important;
|
|
1114
|
-
background: rgba(255, 255, 255, 0.95) !important;
|
|
1115
|
-
border: 3px solid rgba(255, 255, 255, 0.3) !important;
|
|
1116
|
-
color: #000 !important;
|
|
1117
|
-
cursor: pointer !important;
|
|
1118
|
-
display: flex !important;
|
|
1119
|
-
align-items: center !important;
|
|
1120
|
-
justify-content: center !important;
|
|
1121
|
-
transition: all 0.3s ease !important;
|
|
1122
|
-
margin-bottom: 20px !important;
|
|
1123
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
.uvf-play-button:hover {
|
|
1127
|
-
background: #fff !important;
|
|
1128
|
-
transform: scale(1.15) !important;
|
|
1129
|
-
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4) !important;
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
.uvf-play-button svg {
|
|
1133
|
-
width: 40px !important;
|
|
1134
|
-
height: 40px !important;
|
|
1135
|
-
margin-left: 4px !important;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
.uvf-play-message {
|
|
1139
|
-
color: white !important;
|
|
1140
|
-
font-size: 18px !important;
|
|
1141
|
-
font-weight: 600 !important;
|
|
1142
|
-
text-align: center !important;
|
|
1143
|
-
opacity: 0.95 !important;
|
|
1144
|
-
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5) !important;
|
|
1145
|
-
}
|
|
1146
|
-
`;
|
|
1147
|
-
|
|
1148
|
-
// Add to page if not already added
|
|
1149
|
-
if (!document.getElementById('uvf-play-overlay-styles')) {
|
|
1150
|
-
style.id = 'uvf-play-overlay-styles';
|
|
1151
|
-
document.head.appendChild(style);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
// Add to player
|
|
1155
|
-
if (this.playerWrapper) {
|
|
1156
|
-
this.playerWrapper.appendChild(overlay);
|
|
1157
|
-
this.debugLog('✅ Play overlay added to player wrapper');
|
|
1158
|
-
} else {
|
|
1159
|
-
this.debugError('❌ Cannot show play overlay - playerWrapper not found');
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
private hidePlayOverlay(): void {
|
|
1164
|
-
this.debugLog('🔇 Hiding play overlay');
|
|
1165
|
-
const overlay = document.getElementById('uvf-play-overlay');
|
|
1166
|
-
if (overlay) {
|
|
1167
|
-
overlay.remove();
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
1024
|
|
|
1171
1025
|
/**
|
|
1172
1026
|
* Show YouTube-style unmute button when video autoplays muted
|
|
@@ -1365,8 +1219,6 @@ export class WebPlayer extends BasePlayer {
|
|
|
1365
1219
|
this.video.pause();
|
|
1366
1220
|
}
|
|
1367
1221
|
|
|
1368
|
-
// Hide the play overlay if it exists
|
|
1369
|
-
this.hidePlayOverlay();
|
|
1370
1222
|
// Hide unmute button when video starts playing with sound
|
|
1371
1223
|
if (!this.video.muted) {
|
|
1372
1224
|
this.hideUnmuteButton();
|