Availability Per Account Type

Trial

Lite

Pro

White Label

WL – Custom

Introduction

You will be able to use the Region_Lock_Player() functionto show/hide your player depending on if it is allowed to be viewed in a certain group of countries.

Notes:

Getting Started

Step 1. Place this script shown below in your website’s header tag. 

Sample Code – Click to expand / collapse

<script>
  var PDiv;
  var Regions;
  var Count = 0;
  displayPlayer = function(latitude,longitude){
    var request = new XMLHttpRequest();
    var method  = 'GET';
    var url     = 'https://maps.googleapis.com/maps/api/geocode/json?latlng='+latitude+','+longitude+'&sensor=true';
    var async   = true;
         
    request.open(method, url, async);
      request.onreadystatechange = function(){
        if(request.readyState == 4 && request.status == 200){
          var data = JSON.parse(request.responseText);
          var address = data.results[0].address_components[5].short_name;
          for(i = 0; i < Regions.length; i++){
            if(address == Regions[i]){
              Count++;
            }else{
              if(i == (Regions.length-1) && Count == 0){
                PDiv.innerText = "You are located outside of the allowed region for this video."
              }
            }
          }
          PDiv.style.display = 'block';
      }
    };
    request.send();
  };
 
  successCallback = function(position){
    var x = position.coords.latitude;
    var y = position.coords.longitude;
    displayPlayer(x,y);
  };
       
  errorCallback = function(error){
    var errorMessage = 'Unknown error.';
    switch(error.code) {
      case 1:
        errorMessage = 'This player is region locked and permission to use location tracking must be allowed to display this video.';
        break;
      case 2:
        errorMessage = 'Position unavailable.';
        break;
      case 3:
        errorMessage = 'Timeout.';
        break;
    }
    PDiv.innerText     = errorMessage;
    PDiv.style.display = 'block';
  };
 
  options = {
    enableHighAccuracy: true,
    timeout: 1000,
    maximumAge: 0
  };
 
  Region_Lock_Player = function(D, R){
    PDiv    = document.getElementById(D);
    Regions = R;
    navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options);
  };
</script>

Step 2. Place this script in the body of your web page where you wish the player to show up.

Sample Code – Click to expand / collapse

<div id="Container" style="display:none;">
    Player Embed Code Here
</div>
<script>
  var D = 'Container';
  var R = ['US', 'CA'];
  Region_Lock_Player(D, R);
</script>

Step 3.  Log into your EZWebPlayer account and grab your player’s JavaScript embed code while making sure you have HTTPS Environment selected.

Step 4.  Replace the line from Step 2 that saysPlayer Embed Code Here with your player code.

Sample Code – Click to expand / collapse

<div id="Container" style="display:none;">
  <script src="https://d3kedutmscl43l.cloudfront.net/Scripts/player.min.js" type="text/javascript"></script>
  <script type="text/javascript">
    var player23113= new Player({player:"player23113",videoid:"4jdUT1I", userid: "c1cfc02b-4528-47de-9e4c-fc3b7ee5b90f"});
    jqPlayer(document).ready(function() { player23113.GetVideoInfo();  });
  </script>
  <div id="player23113" style="width:940px;height:529px;"></div><br/>
</div>
<script>
  var D = 'Container';
  var R = ['US', 'CA'];
  Region_Lock_Player(D, R);
</script>

Region_Lock_Player() – Pass it 2 variables.

D‘Container’The value of the Div’s ID attribute containing the player’s embed code.
R[‘US’, ‘CA’]An array containing a or group of regions/countries IS02 short code values that can be found on http://www.fao.org/countryprofiles/iso3list/en/# allowed to see this player.

Resulting Player