Embed a YouTube live stream with chat
Show a YouTube live stream and its live chat side by side in Teachfloor using two iframe embed codes.
Written by Filippo Schiano di Pepe
Updated
Embedding a YouTube live stream with its live chat lets your audience watch and interact without leaving your platform. You need two separate HTML <iframe> elements: one for the video and one for the chat.
Get the video embed code
YouTube generates the standard embed code for the live stream video:
- Go to your live stream's page on YouTube.
- Click Share.
- Select Embed.
Copy the entire block of code. It looks similar to this:
<iframe width="560" height="315" src="https://www.youtube.com/embed/YOUR_VIDEO_ID" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>Create the chat embed code
Next, create the <iframe> for the live chat by hand. It is separate from the video embed code. Use the correct URL format and include your domain for security:
<iframe width="350" height="500" src="https://www.youtube.com/live_chat?v=YOUR_VIDEO_ID&embed_domain=app.teachfloor.com" frameborder="0"></iframe>Combine both codes
Paste both <iframe> blocks into the HTML where you want them to appear. Place them side by side or one above the other:
<iframe width="560" height="315" src="https://www.youtube.com/embed/YOUR_VIDEO_ID" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
<iframe width="350" height="500" src="https://www.youtube.com/live_chat?v=YOUR_VIDEO_ID&embed_domain=app.teachfloor.com" frameborder="0"></iframe>To add embed code to a lesson, use the Embed element.
Adjust width and height
You can change the width and height attributes of both <iframe> elements to fit your layout. The chat is usually narrower than the video player.
Did this answer your question?