THEOplayer 2.X Demo: adblock detection

This page demonstrates how you can handle adblockers. There are several options available:

  • You can block the player from playing the content and/or
  • You can show custom behaviour

 

JavaScript code:

// set player
var element = document.querySelector('#video-container'),
    player = new THEOplayer.Player(element, {
        libraryLocation : 'http://cdn.theoplayer.com/dash/theoplayer/'
    });

// add an eventlistener to get custom behavior if there is an ad error
player.ads.addEventListener('aderror', function (event) {
    // do something
});

// set the player source with ads and the blockContentIfAdError property
player.source = {
    sources: {
        src: 'http://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest(format=m3u8-aapl)'
    },
    ads: [{
        sources: 'http://cdn.theoplayer.com/demos/advertisement/livereal-no-skip.xml'    
    }],
    // set this to true if you want to block the content
    // default value is false
    blockContentIfAdError: true
}