A React library for streaming from XR devices on ManageXR
npm install @managexr/react-streamingThis package allows organizations managing XR devices with ManageXR to embed the ManageXR web console's streaming functionality in their own React apps. Devices must be actively enrolled with ManageXR in order to stream.
See our API Docs for instructions on authenticating API requests.
The API key used in the request must have access to every device specified. The returned token will authenticate the SDK to stream only those devices. To stream additional devices, request a new token.
Request:
``bash`
curl --request POST \
--url https://managexrapi.com/v1/devices/generate-streaming-sdk-token \
--header 'Authorization: Basic
--header 'Content-Type: application/json' \
--data '{ "deviceIds": ["device_id_1", "device_id_2"] }'
Response:
`json`
{ "token": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
The connection process will start as soon as the hook is rendered. To end the stream, simply stop rendering the component that contains the hook.
`tsx
import { useDeviceStream } from '@managexr/react-streaming'
const StreamingComponent = ({ deviceId, token }) => {
const { videoRef } = useDeviceStream(deviceId, token)
return (
API
$3
| Argument | Description |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
deviceId | The id (serial) of the device to stream from. This device must be registered with ManageXR and have the ManageXR Admin App installed. |
| token | An authentication token returned by the generate-streaming-sdk-token endpoint. The token must include the provided deviceId. |
| options | See DeviceStreamOptions |DeviceStream$3
| Option | Default | Description |
| ----------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
endOtherStreamAutomatically | false | When true, if the requested device is already streaming to another computer, that stream will be ended automatically. The error_already_streaming status will not be emitted. |$3
| Property | Description |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
videoRef | Set this as the ref of the