Checking for Ad Blockers

In this topic, you will learn how to check if an ad blocker is in use.

Using the usingAdBlocker() method

Brightcove Player has as method that checks to see if an ad blocker is being used by the browser playing your video. This method is usingAdBlocker(). Once the determination is made if an ad blocker is detected, your business rules will guide you on further actions. In the following example three ads will be displayed during the video, or if an ad blocker is detected a message is displayed below the player.

In case you don't have an ad blocker installed for testing, for this example the message boxed in red is displayed when an ad blocker is detected:


The following code is a full example of using the usingAdBlocker() method. Basically the code does the following:

  • Uses a promise to check and see if an ad blocker is detected.
  • If yes, a paragraph is dynamically created and inserted into a pre-existing div.
<!doctype html>

<meta charset="UTF-8">
<title>Untitled Document</title>


  <div style="width: 600px;">
    <video-js id="myPlayerID"
      width="600" height="337.5" class="vjs-fluid"></video-js>
  <script src=""></script>
  <div id="ad-blocker-note"></div>
    videojs.getPlayer('myPlayerID').ready(function () {
      var myPlayer = this;
      myPlayer.usingAdBlocker().then( hasBlocker => {
        if (hasBlocker) {
          var newP = document.createElement("p");
          newP = '<strong>Ads will not play as you are using an ad blocker.</strong>';
          document.getElementById("ad-blocker-note").insertAdjacentHTML('afterbegin', newP);


Of course, you can use an if statement for the JavaScript logic.

videojs.getPlayer('myPlayerID').ready(function () {
  var myPlayer = this;
  if (myPlayer.usingAdBlocker()) {
    var newP = document.createElement("p");
    newP = 'This ad will not play as you are using an ad blocker.';
    document.getElementById("ad-blocker-note2").insertAdjacentHTML('afterbegin', newP);