Basic Iframe Integeration
Learn how to integrate the Streampixel iframe into your frontend, manage keyboard and mouse inputs, and ensure smooth interaction.
Overview
This guide explains how to embed the Streampixel iframe into your frontend, handle input settings for seamless user interaction, and ensure compliance with autoplay policies. It also covers focus management when integrating custom UI controls.
1. Embedding the Iframe
To get started, embed the Streampixel iframe into your frontend with the following configuration:
Key Attributes
src
: Replaceproject-id
with the actual ID of your Streampixel project.allow="autoplay; fullscreen"
: Enables autoplay and fullscreen features.allowfullscreen
: Ensures the stream can enter fullscreen mode.style
: Customize the iframe’s appearance, such as width and height.
Always include allow="autoplay; fullscreen"
to enable autoplay and fullscreen functionality.
2. Input Settings for Keyboard and Mouse
To ensure the stream is fully interactive, handle input focus properly for keyboard and mouse inputs.
Keyboard Input
When users interact with the iframe, ensure it gains focus to capture keyboard input:
Mouse Input
Mouse interactions typically work out of the box. Ensure the iframe is styled appropriately to cover the desired area.
3. Focus Management for Custom UI Controls
If your frontend includes buttons or controls outside the iframe (e.g., Mute, Unmute, or custom settings), clicking those controls shifts focus away from the iframe. To maintain seamless interaction with the stream, you must restore focus to the iframe after handling button clicks.
Example: Custom UI with Focus Restoration
Ensure the iframe regains focus after users interact with external buttons or controls.. Use iframe.focus()
after handling button clicks.
Last updated