How do I integrate Google AdSense with Video.js without showing both HTML and Video.js players simultaneously?

I have integrated a standard HTML video player into my application for video playback. To incorporate Google AdSense advertisements into the video content, I introduced Video.js along with the Video.js IMA plugin. This setup successfully displays ads as intended.

However, an issue has arisen where it appears as though there are two separate video players on the page: the original HTML video player and the newly added Video.js player. This duplication is not the desired outcome, and Iā€™m looking for a solution to seamlessly integrate ads without having two distinct video players visible to the user.

How can I resolve this issue to ensure a unified video playback experience that incorporates Google AdSense ads without the visual clutter of dual players?

1 Like

Hey @lvan!

To use Google AdSense with Video.js while avoiding the simultaneous display of the HTML and Video.js players, you need to perform a transition entirely to the Video.js framework. This ensures that your webpage hosts a single, integrated video playback system that can also manage Google AdSense ads effectively.

Follow the steps given below:

1. Eliminate the HTML Video Element: Begin by removing the HTML <video> element and replacing it with an ā€˜

ā€™ element designated for the Video.js player. This change prevents the overlap of two video players on your webpage.

2. Set Up Video.js: Within the newly added element, initiate Video.js. Ensure you have incorporated both the Video.js library and the IMA plugin into your project. Through JavaScript, instantiate the Video.js player in this, configuring it with your video sources and the IMA plugin for ad management.

3. Configure Ad Display with IMA Plugin: Adjust the settings of the IMA plugin to integrate Google AdSense ads seamlessly. Specify your ad settings, including the ad tag URLs, ensuring that the plugin manages ad playback within the Video.js framework effectively.

4. Adjust CSS for Visibility: Modify your CSS to make sure only the Video.js player is displayed, occupying the intended space on your webpage. Remove or alter any CSS previously applied to the standard HTML video player.

5. Conduct Extensive Testing: Perform detailed testing across various devices and browsers to verify that only the Video.js player is visible and that it correctly displays Google AdSense ads. This step is crucial to uncover and fix any issues that might lead to the display of multiple players.

This is how you can do this task. Do let me know if you need further help.

Thank you

How to enhance user experience with custom ad configurations in video.js?