unified-video-framework 1.4.264 → 1.4.266

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.
@@ -1248,6 +1248,9 @@ export class WebPlayer extends BasePlayer {
1248
1248
  this.youtubePlayerReady = true;
1249
1249
  this.debugLog('YouTube player ready');
1250
1250
 
1251
+ // Hide custom controls immediately for YouTube
1252
+ this.hideCustomControls();
1253
+
1251
1254
  // Set initial volume
1252
1255
  if (this.youtubePlayer) {
1253
1256
  const volume = this.config.volume ? this.config.volume * 100 : 100;
@@ -1256,6 +1259,17 @@ export class WebPlayer extends BasePlayer {
1256
1259
  if (this.config.muted) {
1257
1260
  this.youtubePlayer.mute();
1258
1261
  }
1262
+
1263
+ // Detect if YouTube video is Live and handle controls
1264
+ this.detectYouTubeLiveStatus();
1265
+
1266
+ // Try to get video title from YouTube API
1267
+ this.getYouTubeVideoTitle();
1268
+
1269
+ // Update metadata UI after player is ready
1270
+ setTimeout(() => {
1271
+ this.updateMetadataUI();
1272
+ }, 500);
1259
1273
  }
1260
1274
 
1261
1275
  // Start time tracking
@@ -1263,6 +1277,41 @@ export class WebPlayer extends BasePlayer {
1263
1277
 
1264
1278
  this.emit('onReady');
1265
1279
  }
1280
+
1281
+ /**
1282
+ * Hide custom controls when YouTube is active
1283
+ */
1284
+ private hideCustomControls(): void {
1285
+ // Apply youtube-mode class to wrapper which hides all custom controls via CSS
1286
+ if (this.playerWrapper) {
1287
+ this.playerWrapper.classList.add('youtube-mode');
1288
+ this.debugLog('🎬 youtube-mode class applied - custom controls hidden');
1289
+ }
1290
+
1291
+ // Fallback: direct DOM manipulation if class approach doesn't work
1292
+ setTimeout(() => {
1293
+ const controlsBar = document.getElementById('uvf-controls');
1294
+ const topBar = document.querySelector('.uvf-top-bar');
1295
+ const centerPlay = document.getElementById('uvf-center-play');
1296
+
1297
+ if (controlsBar) {
1298
+ controlsBar.style.display = 'none';
1299
+ controlsBar.style.visibility = 'hidden';
1300
+ controlsBar.style.pointerEvents = 'none';
1301
+ }
1302
+ if (topBar) {
1303
+ (topBar as HTMLElement).style.display = 'none';
1304
+ (topBar as HTMLElement).style.visibility = 'hidden';
1305
+ (topBar as HTMLElement).style.pointerEvents = 'none';
1306
+ }
1307
+ if (centerPlay) {
1308
+ centerPlay.style.display = 'none';
1309
+ centerPlay.style.visibility = 'hidden';
1310
+ }
1311
+
1312
+ this.debugLog('🎬 Fallback: Direct DOM manipulation applied');
1313
+ }, 100);
1314
+ }
1266
1315
 
1267
1316
  private onYouTubePlayerStateChange(event: any): void {
1268
1317
  const state = event.data;
@@ -1270,10 +1319,10 @@ export class WebPlayer extends BasePlayer {
1270
1319
  switch (state) {
1271
1320
  case window.YT.PlayerState.PLAYING:
1272
1321
  this.state.isPlaying = true;
1273
- this.state.isPaused = false;
1274
- this.state.isBuffering = false;
1275
- this.updateYouTubeUI('playing');
1276
- this.emit('onPlay');
1322
+ this.state.isPaused = false;
1323
+ this.state.isBuffering = false;
1324
+ this.updateYouTubeUI('playing');
1325
+ this.emit('onPlay');
1277
1326
  break;
1278
1327
 
1279
1328
  case window.YT.PlayerState.PAUSED:
@@ -1350,7 +1399,66 @@ export class WebPlayer extends BasePlayer {
1350
1399
  });
1351
1400
  }
1352
1401
 
1402
+ /**
1403
+ * Get YouTube video title from the player API
1404
+ */
1405
+ private getYouTubeVideoTitle(): void {
1406
+ if (!this.youtubePlayer || !this.youtubePlayerReady) return;
1407
+
1408
+ try {
1409
+ // Try to get video data from YouTube player
1410
+ const videoData = this.youtubePlayer.getVideoData();
1411
+ if (videoData && videoData.title) {
1412
+ this.debugLog('Got YouTube title from player API:', videoData.title);
1413
+
1414
+ // Update source metadata with the correct title
1415
+ if (this.source && this.source.metadata) {
1416
+ this.source.metadata.title = videoData.title;
1417
+ }
1418
+
1419
+ // Update UI immediately
1420
+ this.updateMetadataUI();
1421
+ }
1422
+ } catch (error) {
1423
+ this.debugWarn('Could not get YouTube video title from API:', error);
1424
+ }
1425
+ }
1426
+
1427
+ /**
1428
+ * Detect if YouTube video is Live
1429
+ */
1430
+ private detectYouTubeLiveStatus(): void {
1431
+ if (!this.youtubePlayer || !this.youtubePlayerReady) return;
1432
+
1433
+ try {
1434
+ const videoData = this.youtubePlayer.getVideoData();
1435
+ this.isYouTubeLive = videoData?.isLive || false;
1436
+
1437
+ this.debugLog('YouTube Live status:', {
1438
+ isLive: this.isYouTubeLive,
1439
+ videoId: videoData?.video_id
1440
+ });
1441
+
1442
+ } catch (error) {
1443
+ this.debugWarn('Could not detect YouTube Live status:', error);
1444
+ // Fallback: check duration - Live videos typically have duration = 0
1445
+ try {
1446
+ const duration = this.youtubePlayer.getDuration();
1447
+ this.isYouTubeLive = !duration || duration === 0;
1448
+
1449
+ this.debugLog('YouTube Live detected via duration check:', {
1450
+ duration,
1451
+ isLive: this.isYouTubeLive
1452
+ });
1453
+ } catch (e) {
1454
+ this.debugWarn('Could not check YouTube duration for Live detection:', e);
1455
+ }
1456
+ }
1457
+ }
1458
+
1353
1459
  private youtubeTimeTrackingInterval: NodeJS.Timeout | null = null;
1460
+ private isYouTubeLive: boolean = false;
1461
+ private useYouTubeNativeControls: boolean = false;
1354
1462
 
1355
1463
  private startYouTubeTimeTracking(): void {
1356
1464
  if (this.youtubeTimeTrackingInterval) {
@@ -6246,6 +6354,17 @@ export class WebPlayer extends BasePlayer {
6246
6354
  display: flex !important;
6247
6355
  }
6248
6356
 
6357
+ /* YouTube Mode - Hide all custom controls */
6358
+ .uvf-player-wrapper.youtube-mode .uvf-controls-bar,
6359
+ .uvf-player-wrapper.youtube-mode .uvf-top-bar,
6360
+ .uvf-player-wrapper.youtube-mode .uvf-top-gradient,
6361
+ .uvf-player-wrapper.youtube-mode .uvf-controls-gradient,
6362
+ .uvf-player-wrapper.youtube-mode .uvf-center-play-container {
6363
+ display: none !important;
6364
+ visibility: hidden !important;
6365
+ pointer-events: none !important;
6366
+ }
6367
+
6249
6368
  /* Hide all controls if controls prop is false */
6250
6369
  .uvf-player-wrapper.controls-disabled .uvf-controls-bar,
6251
6370
  .uvf-player-wrapper.controls-disabled .uvf-top-bar,