Skip to main content
Version: v1.1

PixelStreaming settings

Connects to running STUN and TURN Servers.

Module installation

yarn add pixel-streaming

Usage

import React from "react";

// libs
import PixelStreaming from "pixel-streaming";

export default function Player(props) {
const refPixelStreaming = React.useRef(null);

return (
<PixelStreaming
ref={refPixelStreaming}
onLoad={(payload) => {
// console.warn('loaded', payload);
}}
onConnect={() => {
// console.warn('connected');
}}
onRestart={() => {
// console.warn('onRestart');
}}
onError={(payload) => {
// console.error('error', payload);
}}
onClose={(payload) => {
// console.error('closed', payload);
}}
onCommand={(payload) => {
// console.warn('command', payload);
}}
onCallback={(payload) => {
// console.warn('callback', payload);
}}
onProgress={(payload) => {
// console.warn('progress', payload);
}}
autoConnect={true}
quality={1}
isDev={true}
host="http://127.0.0.1"
port={80}
>
{(payload) => <div style={{ padding: 30 }}>{props.children}</div>}
</PixelStreaming>
);
}

Props

PropDescriptionType
autoConnectConnect to stream automatically. 
Default: true
bool
hostString host to url with signal server.
If host starts wih https then it will be used wss 
If starts with http then will be used ws
Example: https://uuid1234567890.streamdomain.com
string
portPort of signal server.
Default: 80
int
childrenThe function receives parameters and renders the nested component
Example: {(payload) => (...)}

Incoming parameters: 
stateObject with state data
initConnection() — If autoConnect={false}, then use the initConnection() function to manually connect to the stream.
function
onLoadWhen the stream startedfunction
onConnectCalled when the stream is running
onRestartCalled when the stream is restartedfunction
onErrorCalled on errors in the webrtc connection
onCloseCalled if the webrtc connection is closed
onCallbackCalled when the stream server sends callbacks
onProgressReturn progress in percentage based on secondsToStartfunction

Reference object data

refPixelStreaming.current.state

VariableDefaultDescription
aggregated_statsfalse
callback_callerfalse
callback_loadingfalse
closedfalse
connectfalse
errorfalse
last_interactionnull
loadedfalse
mouse_movingfalse
quality_speedfalse
resolution_multiplier1.5
stream_configfalse
users_count0
window_size{width: 0, height: 0}

Send command to stream server

refPixelStreaming.current.emit({
verification_id: undefined, //server response with execute command by verification id
command: 'user_sound', //key of command
request: {
body: {
volume: 1,
}
},
})

Event for handling callbacks from Unreal Engine

To get callbacks, you can use the built-in method:

<PixelStreaming onCallback={payload => console.log(payload) } />}

const eventKey = 'metaeditor_callback'
document.addEventListener(eventKey, event => {
response = event.detail
console.log(response)
})

/*
// Response Example:

{
"verification_id": "autogenerated__1",
"initiator": "browser",
"command": "user_sound",
"request": {
"body": {
"volume": 1
}
},
"response": {
"time": "Apr 20, 2022, 6:20:15 AM",
"body": {
"volume": 1
}
}
}
*/

Attention!

  • React v.17.0.2

  • Apply style pointerEvents: 'none' to all JSX elements that overlap the stream.

Built With