@streampixel/web-sdk. Names and behaviour can still change before the stable 2.0.0 release. See the changelog.What you build
One file,index.html. It shows:
- your app’s video, filling the browser window;
- one line of text that says what is happening: “Connecting…”, “In queue…”, or why the stream ended;
- a few buttons that appear only when they are needed: start, sound, “still there?”, start again.
<script> tag.
Before you start
Build the page
Create the file
my-stream. Inside it, create a file named index.html.index.html, with the code above in it.Serve the folder
- Python
- Node.js
py -m http.server 8000.Serving HTTP on. Your page is at http://localhost:8000.https or from localhost. A file you open by double-click has an address that starts with file://, which is neither.Open the page
Copy your project ID
- Sign in at dashboard.streampixel.io and open your project.
- Click the Project ID button to copy it.
0123456789abcdef01234567 (a made-up example: no project has this ID).Paste it into the file
index.html, find line 43 and replace YOUR_PROJECT_ID with your ID. Keep the quotes.Use your app
What the line at the top tells you
How the page works
The file has five parts. You can change any of them.1. A box for the video
#stream { width: 100%; height: 100%; } makes it fill the window. To show the stream in part of a page, give the box another size.
2. The SDK
StreampixelSDK. It is small: the code that runs the stream is downloaded later, when your page starts a stream. How it works explains why.
3. Starting the stream
Streampixel.create() needs two things: your project ID (the option is named appId) and the container. It gives back the stream object, which the rest of the script uses.
When the stream cannot start, create() throws an error instead. The explain() function in the file turns that error into a sentence for the status line.
4. Showing what happens
stream.state.kind is its name: connecting, queued, streaming, ended and a few more. The SDK calls render() each time the state changes, and render() writes the line at the top and shows or hides the buttons.
5. What the viewer needs from your page
The SDK draws the video and nothing else. Everything a viewer clicks is yours to draw. This page has the smallest set that works:What this page leaves out
What this page leaves out
- a loading screen with your project’s logo and loading texts;
- a text field on phones, when your app asks the viewer to type;
- a Save button for files and an Open button for links that your app sends, on phones and tablets;
- a notice when the viewer’s network forces a slower connection;
- controls such as fullscreen.
@streampixel/ui package draws all of them, and the five above, with one line of code. It needs npm: see the Quick start. To draw them yourself, see the Cookbook.If something goes wrong
Read the line at the top of your page first. Then find it here.The line still says: Paste your project ID into PROJECT_ID
The line still says: Paste your project ID into PROJECT_ID
index.html in the folder you are serving.server: Invalid project id
server: Invalid project id
No project has this ID
No project has this ID
This project is switched off or has no active build
This project is switched off or has no active build
The page stays on Loading… or says the Streampixel script did not load
The page stays on Loading… or says the Streampixel script did not load
https://js.streampixel.io/v2/loader.js. Check your internet connection. Switch off any ad blocker for this page and reload.The player could not be loaded (…)
The player could not be loaded (…)
Could not reach Streampixel
Could not reach Streampixel
It stays on In queue…
It stays on In queue…
The video plays and there is no sound
The video plays and there is no sound
A password field appears
A password field appears
The browser goes to a sign-in page
The browser goes to a sign-in page
It ends with: Access was refused
It ends with: Access was refused
http://localhost:8000. See The allowed-domains list.It ends with: Disconnected due to inactivity
It ends with: Disconnected due to inactivity
It ends with: This network blocks the connection the stream needs
It ends with: This network blocks the connection the stream needs
It ends with another sentence
It ends with another sentence
Next steps
How it works
Build a real page
Talk to your Unreal app
Options
create() accepts.