Skip to content

feat(sia-video-source): expose source info - #1199

Merged
pcfreak30 merged 1 commit into
developfrom
feat/sia-video-source-source-info
Sep 24, 2026
Merged

pcfreak30 merged 1 commit into
developfrom
feat/sia-video-source-source-info

Conversation

@pcfreak30

@pcfreak30 pcfreak30 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Adds a siaSourceInfoFeature for metadata returned with SOURCE_OK.

The feature exposes container, MIME, tracks, duration, and MSE mode through selectSiaSourceInfo and useSiaSourceInfo(). It clears metadata when the source changes or detaches.


Summary

This PR adds source information exposure to the Sia video source for Video.js v10 players. It surfaces the typed SourceInfo payload the worker already sends on SOURCE_OK through a new DOM event, a player store feature/selector, and a React hook — with no protocol changes.

What changed

New sia-source-info-change event on the host

  • SiaVideoSource now emits a typed sia-source-info-change DOM event on both its own EventTarget and the attached <video> element.
  • The event detail mirrors the host's existing per-load window:
    • { active: true, info } — emitted exactly once when the current request's SOURCE_OK acknowledges the load, carrying the exact SourceInfo the worker vouched for (container, mime, mode, track codecs, durationSeconds — which may be null).
    • { active: false } — emitted exactly once at every load boundary: fresh source/load, reloadConfiguration/reattach replay, recovery restart, detach, and destroy.
  • Guards prevent duplicate opens/closes and stale/superseded SOURCE_OK replies from re-opening or leaking info across loads.
  • The SourceInfo payload is treated as immutable and forwarded without mutation.

New shared player feature + selector

  • Added siaSourceInfoFeature and selectSiaSourceInfo for non-React Video.js stores.
  • The store slice is exposed under a single collision-safe sourceInfo key as { active: false } | { active: true; info }, avoiding key collisions with the existing recovery feature's top-level active key in the flat player store.
  • The feature subscribes to the host's event through the player's media, resets to inert on detach, and never lets a stale info leak.

New React hook

  • Added useSiaSourceInfo() behind /react, reading the exact same selector slice as non-React consumers.

Shared siaFeatures tuple extended

  • siaFeatures is now a mutable tuple of all three features: [siaRecoveryFeature, siaLoadFeature, siaSourceInfoFeature].
  • Works with both non-React combine(...) and React createPlayer({ features: siaFeatures }).

Docs

  • README updated with usage examples for both vanilla Video.js and React consumers, including how to read durationSeconds, which may be null, and a clear note that an open window means the worker pipeline accepted the source — not that the load is playable/ready.

Tests

  • Added comprehensive specs covering host event behavior (open/close exactly once, stale SOURCE_OK handling, detach/destroy/recovery/reload boundaries, immutable payload), the shared store feature and selector, React hook integration, the shared tuple, and declaration guards ensuring the root entry stays consumable without @videojs/react.

- Mirror accepted source metadata into Video.js state
- Extend shared features with React and lifecycle coverage
@pcfreak30 pcfreak30 changed the title feat/sia video source source info feat(sia-video-source): expose source info Sep 24, 2026
@kody-ai

kody-ai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@pcfreak30
pcfreak30 marked this pull request as ready for review September 24, 2026 20:29
@pcfreak30
pcfreak30 merged commit e64d6db into develop Sep 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant