DEV Community

Cover image for Recreating Ambient Mode from Youtube Videos
Bishal Pahari
Bishal Pahari

Posted on

Recreating Ambient Mode from Youtube Videos

Briefly About Ambient Mode

In October 2022, YouTube introduced Ambient Mode, an immersive feature that enhances the viewing experience by extending the video's colors into the interface background. This effect, available exclusively in Dark Mode, reduces eye strain and adds a cinematic touch to video playback.

In this blog, we'll create a dynamic ambient mode similar to YouTube's Ambient Mode.

Step by Step Guide

It's essentially two different stacked videos playing in sync with effects.

Image Description

First, wrap two video elements within a div.container. Here, we'll use the first video element for the ambient mode and the second as our main video. Ensure you mute and remove the controls of the ambient video element.

Image description

Image description

Next, set the container's position to relative and the second video's position to absolute, positioning the main video over the ambient one.

Image description

At this stage, your setup should look similar to the picture above.

Image description

Now, scale up the ambient mode video element so it expands and becomes visible.

Image description

Add some blur to the ambient mode video element.

Image description

Finally, reduce the opacity of the ambient mode video element to enhance the effect.

If you want to create a dynamic ambient mode that syncs with the main video, you can achieve this using JavaScript. Configure actions so that the main video's controls also affect the ambient mode video.

Thanks for following along! I hope you found this guide helpful and easy to understand.

Youtube blog: Open (Watch YouTube in ambient mode)

Demo Site: Youtube-ambient-mode

Source Code: Github

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more