unified-video-framework 1.4.264 → 1.4.265

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,36 @@ 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
+ const controlsBar = document.getElementById('uvf-controls');
1286
+ const topBar = document.querySelector('.uvf-top-bar');
1287
+ const topGradient = document.querySelector('.uvf-top-gradient');
1288
+ const controlsGradient = document.querySelector('.uvf-controls-gradient');
1289
+
1290
+ if (controlsBar) {
1291
+ controlsBar.style.display = 'none !important';
1292
+ controlsBar.style.visibility = 'hidden';
1293
+ controlsBar.style.pointerEvents = 'none';
1294
+ }
1295
+ if (topBar) {
1296
+ (topBar as HTMLElement).style.display = 'none';
1297
+ (topBar as HTMLElement).style.visibility = 'hidden';
1298
+ }
1299
+ if (topGradient) {
1300
+ (topGradient as HTMLElement).style.display = 'none';
1301
+ (topGradient as HTMLElement).style.visibility = 'hidden';
1302
+ }
1303
+ if (controlsGradient) {
1304
+ (controlsGradient as HTMLElement).style.display = 'none';
1305
+ (controlsGradient as HTMLElement).style.visibility = 'hidden';
1306
+ }
1307
+
1308
+ this.debugLog('🎬 Custom controls hidden for YouTube player');
1309
+ }
1266
1310
 
1267
1311
  private onYouTubePlayerStateChange(event: any): void {
1268
1312
  const state = event.data;
@@ -1270,10 +1314,10 @@ export class WebPlayer extends BasePlayer {
1270
1314
  switch (state) {
1271
1315
  case window.YT.PlayerState.PLAYING:
1272
1316
  this.state.isPlaying = true;
1273
- this.state.isPaused = false;
1274
- this.state.isBuffering = false;
1275
- this.updateYouTubeUI('playing');
1276
- this.emit('onPlay');
1317
+ this.state.isPaused = false;
1318
+ this.state.isBuffering = false;
1319
+ this.updateYouTubeUI('playing');
1320
+ this.emit('onPlay');
1277
1321
  break;
1278
1322
 
1279
1323
  case window.YT.PlayerState.PAUSED:
@@ -1350,7 +1394,66 @@ export class WebPlayer extends BasePlayer {
1350
1394
  });
1351
1395
  }
1352
1396
 
1397
+ /**
1398
+ * Get YouTube video title from the player API
1399
+ */
1400
+ private getYouTubeVideoTitle(): void {
1401
+ if (!this.youtubePlayer || !this.youtubePlayerReady) return;
1402
+
1403
+ try {
1404
+ // Try to get video data from YouTube player
1405
+ const videoData = this.youtubePlayer.getVideoData();
1406
+ if (videoData && videoData.title) {
1407
+ this.debugLog('Got YouTube title from player API:', videoData.title);
1408
+
1409
+ // Update source metadata with the correct title
1410
+ if (this.source && this.source.metadata) {
1411
+ this.source.metadata.title = videoData.title;
1412
+ }
1413
+
1414
+ // Update UI immediately
1415
+ this.updateMetadataUI();
1416
+ }
1417
+ } catch (error) {
1418
+ this.debugWarn('Could not get YouTube video title from API:', error);
1419
+ }
1420
+ }
1421
+
1422
+ /**
1423
+ * Detect if YouTube video is Live
1424
+ */
1425
+ private detectYouTubeLiveStatus(): void {
1426
+ if (!this.youtubePlayer || !this.youtubePlayerReady) return;
1427
+
1428
+ try {
1429
+ const videoData = this.youtubePlayer.getVideoData();
1430
+ this.isYouTubeLive = videoData?.isLive || false;
1431
+
1432
+ this.debugLog('YouTube Live status:', {
1433
+ isLive: this.isYouTubeLive,
1434
+ videoId: videoData?.video_id
1435
+ });
1436
+
1437
+ } catch (error) {
1438
+ this.debugWarn('Could not detect YouTube Live status:', error);
1439
+ // Fallback: check duration - Live videos typically have duration = 0
1440
+ try {
1441
+ const duration = this.youtubePlayer.getDuration();
1442
+ this.isYouTubeLive = !duration || duration === 0;
1443
+
1444
+ this.debugLog('YouTube Live detected via duration check:', {
1445
+ duration,
1446
+ isLive: this.isYouTubeLive
1447
+ });
1448
+ } catch (e) {
1449
+ this.debugWarn('Could not check YouTube duration for Live detection:', e);
1450
+ }
1451
+ }
1452
+ }
1453
+
1353
1454
  private youtubeTimeTrackingInterval: NodeJS.Timeout | null = null;
1455
+ private isYouTubeLive: boolean = false;
1456
+ private useYouTubeNativeControls: boolean = false;
1354
1457
 
1355
1458
  private startYouTubeTimeTracking(): void {
1356
1459
  if (this.youtubeTimeTrackingInterval) {