Skip to content

v1.0.4

Choose a tag to compare

@debabin debabin released this 03 Jul 09:22
· 98 commits to main since this release

Improve screen sharing hook

This release improves the screen sharing API with a more flexible useDisplayMedia hook and a more convenient integration flow for media elements.

Features

  • useDeviceList — improved the hook for reading available media devices from navigator.mediaDevices.enumerateDevices(). It now returns the full device list together with pre-grouped audioInputs, audioOutputs, and videoInputs, supports automatic initial loading, exposes manual update and trigger actions, and listens to the native devicechange event to keep the list in sync.
  • useDeviceList — makes it easier to work with media device selection flows by separating microphones, speakers, and cameras out of the box, while still preserving access to the raw devices array when full control is needed.
  • useMediaStream — improved the hook for managing a live mediaDevices.getUserMedia() stream. It now supports both target-element and ref-based usage, exposes start, stop, restart, and apply controls, tracks active and loading states, automatically attaches the stream to a media element, and provides onStart, onStop, and onError callbacks.
  • useDisplayMedia — improved the hook for working with navigator.mediaDevices.getDisplayMedia(). It now supports both target-element and ref-based usage, making it easier to attach a shared screen stream directly to a video element.
  • useDisplayMedia — updated the API to support default constraints through options and per-call constraints through start(constraints), which makes screen and audio sharing scenarios more flexible.
  • useDisplayMedia — added onStart and onStop callbacks for reacting to sharing lifecycle events without extra effects.
  • useDisplayMedia — improved stream lifecycle handling so the hook automatically binds the stream to the media element, tracks active state, and correctly stops sharing when the underlying media tracks end.