@geekapps/silo-elements-nextjs 0.3.12 → 0.3.15

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/dist/index.js CHANGED
@@ -2303,6 +2303,8 @@ function Video({
2303
2303
  abrBandWidthUpFactor: 0.7
2304
2304
  });
2305
2305
  hlsRef.current = hls;
2306
+ let pinnedLevel = -1;
2307
+ let pinnedAudio = -1;
2306
2308
  console.debug("[Silo/hls] loadSource", activeSource.src);
2307
2309
  hls.loadSource(activeSource.src);
2308
2310
  hls.attachMedia(video);
@@ -2327,8 +2329,10 @@ function Video({
2327
2329
  label: t.name ?? t.lang ?? `Track ${i + 1}`
2328
2330
  }))
2329
2331
  );
2330
- setSelectedAudio(hls.audioTrack ?? 0);
2332
+ if (pinnedAudio === -1) setSelectedAudio(hls.audioTrack ?? 0);
2331
2333
  }
2334
+ if (pinnedLevel >= 0) hls.currentLevel = pinnedLevel;
2335
+ if (pinnedAudio >= 0) hls.audioTrack = pinnedAudio;
2332
2336
  setIsLoading(false);
2333
2337
  });
2334
2338
  hls.on(Hls.Events.AUDIO_TRACKS_UPDATED, (_, data) => {
@@ -2342,7 +2346,22 @@ function Video({
2342
2346
  }))
2343
2347
  );
2344
2348
  }
2349
+ if (pinnedAudio >= 0 && hls.audioTrack !== pinnedAudio) {
2350
+ hls.audioTrack = pinnedAudio;
2351
+ }
2352
+ });
2353
+ hls.on(Hls.Events.LEVEL_SWITCHED, (_, data) => {
2354
+ console.debug("[Silo/hls] LEVEL_SWITCHED", data.level);
2355
+ if (pinnedAudio >= 0 && hls.audioTrack !== pinnedAudio) {
2356
+ hls.audioTrack = pinnedAudio;
2357
+ }
2345
2358
  });
2359
+ hls.__pinLevel = (level) => {
2360
+ pinnedLevel = level;
2361
+ };
2362
+ hls.__pinAudio = (track) => {
2363
+ pinnedAudio = track;
2364
+ };
2346
2365
  hls.on(Hls.Events.LEVEL_LOADED, (_, data) => {
2347
2366
  console.debug("[Silo/hls] LEVEL_LOADED level=", data.level, "fragments=", data.details?.fragments?.length);
2348
2367
  });
@@ -2519,6 +2538,7 @@ function Video({
2519
2538
  setSelectedAudio(trackId);
2520
2539
  closeSettings();
2521
2540
  if (hlsRef.current) {
2541
+ hlsRef.current.__pinAudio?.(trackId);
2522
2542
  hlsRef.current.audioTrack = trackId;
2523
2543
  }
2524
2544
  }, [closeSettings]);
@@ -2530,6 +2550,7 @@ function Video({
2530
2550
  closeSettings();
2531
2551
  if (option.type === "auto") {
2532
2552
  if (hlsRef.current) {
2553
+ hlsRef.current.__pinLevel?.(-1);
2533
2554
  hlsRef.current.currentLevel = -1;
2534
2555
  }
2535
2556
  if (dashRef.current) {
@@ -2546,7 +2567,8 @@ function Video({
2546
2567
  return;
2547
2568
  }
2548
2569
  if (option.type === "hls" && hlsRef.current && option.index != null) {
2549
- hlsRef.current.nextLevel = option.index;
2570
+ hlsRef.current.__pinLevel?.(option.index);
2571
+ hlsRef.current.currentLevel = option.index;
2550
2572
  return;
2551
2573
  }
2552
2574
  if (option.type === "dash" && dashRef.current && option.index != null) {