Implementation

Agnoplay provides a simple way to display video- and audio assets on your website or application: it is possible to embed Agnoplay using our JavaScript (JS) implementation, NPM packages (ReactJS, Vue, and Angular), WordPress plugin or iFrame implementation. The player can either resolve a streamsource from the given CDN, or resolve any VMS (Video Management System) source from which the stream source is being obtained. The player can handle any type of stream source, whether it’s HLS, DASH, MP4 or MP3. Note that Agnoplay is compatible with all modern platforms and devices in HTML5 without needing other plugins. The player can be used for all popular desktop platforms such as Windows, Mac and Linux, but also for mobile platforms such as iOS and Android by means of native SDKs.

Embed a video in your native mobile app

iOS & Android SDK

Developers will get access to the Agnoplay iOS or Android repository, from there the readme should be followed thoroughly.

To get access, please consult the Agnoplay team.

Embed Agnoplay in your website

To embed our player in your website there are several options:

  1. Use of NPM packages, which are available here
  2. Use of our JS implementation as documented below
  3. Use of an iFrame implementation
  4. In case you’re using the WordPress platform we’re providing an easy to install Agnoplay WordPress plugin. This plugin can be made available on request, including a readme with installation instructions

All implementation methods provide flexibility to all product owners and developers.

Requirements

First, let us define the requirements for each implementation:

  • Commercials are discussed and agreed upon
  • Agnoplay will be provided access to your CDN for deploying all player related files
  • In case Agnoplay needs to resolve your backend, then the video backend is set up and available for Agnoplay
  • Each asset is represented by a unique identifier
Licenses

To enable the playback of video with the Agnoplay video player an active license is mandatory. You will receive a license key for each active brand in your account. When implementing the player in your app or website, just add a license_key parameter with the corresponding license key for your brand, e.g.

<div id="agnoplayer"></div>

<script crossorigin="anonymous" src="https://player.agnoplay.com/static/agnoplay/js/agnoplay.js"></script>
<script>
  var element = document.getElementById("agnoplayer"),
  config = {
    // required parameters:
    brand: "agnoplay",
    videoId: "Mbdskc9KsAii",
    url: window.location.href,
    license_key: 'sample_license_key'
  };
  var player = window.AGNO.insertPlayer(config, element);
</script>

CDN

When your different DTAP environments have been set up, we advise the following:

ACCEPTANCE

// Latest version
<script src="https://player-acc.agnoplay.com/static/agnoplay/js/agnoplay.js"></script>

// Fixed version
<script src="https://player-acc.agnoplay.com/static/agnoplay/x.y.z/js/agnoplay.js"></script>

PRODUCTION

// Latest version
<script src="https://player.yourdomain.com/static/agnoplay/js/agnoplay.js"></script>

// Fixed version
<script src="https://player.yourdomain.com/static/agnoplay/x.y.z/js/agnoplay.js"></script>

NOTE: during initial setup the agnoplay.com domain will be used as a Production environment, for a swift release.

JS Implementation

Secondly, we start by defining the configuration of the player in the most minimal form. The following settings are possible:

<div id="agnoplayer"></div>

<script crossorigin="anonymous" src="https://player.yourdomain.com/static/agnoplay/js/agnoplay.js"></script>
<script>
  var element = document.getElementById("agnoplayer"),
  config = {
    // required parameters:
    brand: "agnoplay",
    videoId: "Mbdskc9KsAii",
    url: window.location.href
    license_key: 'sample_license_key'
  };
  var player = window.AGNO.insertPlayer(config, element);
</script>

This code fetches the json formatted player configuration from the CDN based on the brand name. In this case the following json file will be retrieved from:

https://player.yourdomain.com/static/api/v1/configs/agnoplay.json

The player will be initiated based on this configuration.

Update Player

The player can be updated with another config

function updatePlayer() {
  var config = {
    // required parameters:
    brand: "agnoplay",
    videoId: "OTHER_VIDEO_ID",
    url: window.location.href,
  };
  window.AGNO.updatePlayerConfig('agnoplayer', config);
  return false; // don't refresh the page
}

Dispose Player

The player can be disposed by the player id

window.AGNO.disposePlayer('agnoplayer');

All the players can be disposed at the same time

window.AGNO.disposeAll();

Principles

Each player comes with a default configuration. The configuration can be changed within the Control Panel (coming soon). During the initialization of the player the configuration settings are applied and its ready for playback.

Now, all configuration settings can be overridden by preference. For example, the above configuration does not come with the autoplay feature. But, if you would like to use it, you can pass an extra parameter like:

...
// required parameters:
brand: "agnoplay",
videoId: "Mbdskc9KsAii",
url: window.location.href
// optional parameters:
autoplay: true // where default configuration was set to false
...

This allows full flexibility to the developer to define and override parameters to enable / disable certain features as desired.

iFrame Implementation

An example of using the iFrame implementation can be found here.

Features

Next to Autoplay, the player comes with lots of features that can be configured. Please continue to browse all features where you'll find more information about what each feature represents, including code examples.

Integrations

Some of the features also come hand in hand with thrid party integrations. Please continue to browse the Integrations section where you'll find more information about what each integation represents, including code examples.

Profiles

Another powerful feature that needs some clarification is profiling. This gives the player possibilities to target specific device + browsers for certain features.

Profiles can be managed in the Control Panel (coming soon) and connected to a player configuration.

Multiple Players

When you want to embed multiple players on the same page, you'll need to define unique element identifiers. Let us give an example:

// id appended with 1
<div id="agnoplayer-1"></div>

// id appended with 2
<div id="agnoplayer-2"></div>

In this way the players are distinguished and isolated for correct playback.

Player Element

The player can be addressed through the AGNO object. In the following example the player element can be retrieved as follow:

window.AGNO.Players.getPlayerById('YOUR_PLAYER_ID').agnoInstance.element;

AGNO Events

The player can be addressed through the AGNO object. The following example shows how to subscribe to AGNO events:

document.addEventListener('agnoLoaded', function(e) {
  // Now you know that the player has been loaded and the instance is available
  // The playerId can be retrieved as follow:
  var playerId = e.detail.playerId;

  // Here you can add code to manipulate the player
}

document.addEventListener('agnoReset', function(e) {
  // Now you know that the player has been resetted
  // The playerId can be retrieved as follow:
  var playerId = e.detail.playerId;

  // Here you can add code to manipulate the player
}

Player Control

The player can be addressed through the AGNO object. The following example shows how the player can be played / paused / stopped:

// Per player
window.AGNO.play('YOUR_PLAYER_ID') // Starts or resumes playback.
window.AGNO.pause('YOUR_PLAYER_ID') // Pauses playback. Playback can be resumed by calling .play().
window.AGNO.stop('YOUR_PLAYER_ID') // Stops playback.
// PLEASE NOTE: ".stop()" releases all resources associated with the currently loaded source.
// A new source can be loaded later on by setting player.source.

// The following helpers will propagate the above behaviours to all players on the page.
window.AGNO.playAll()
window.AGNO.pauseAll()
window.AGNO.stopAll()

// The following helper will propagate the above behaviours to all players on the page except the given one
window.AGNO.pauseAllExcept('YOUR_PLAYER_ID')

Player Events

The player can be addressed through the AGNO object. The following example shows how to subscribe to player events:

var player = Players.getPlayerById('YOUR_PLAYER_ID').agnoInstance;
player.addEventListener('playing', function(e) {
  // do magic
}

Other

The player can be addressed through the AGNO object. Let us provide some other options:

// List all players
window.AGNO.Players.list

// Get Agnoplayer version
window.AGNO.getVersion(function(version) {
// do whatever you want with the version
...
})

// Alternative with Promise
window.AGNO.getVersion().then(function(version) {
// do whatever you want with the version
...

// Get detected browser info by AGNO
window.AGNO.getBrowserInfo(e => {console.log(e)})
...
})

Debugging

window.AGNO has a Players key which is a class that contains a list of all the players on the page with the player id as key. Each ‘Player’ class contains the brand and implementation configuration and the player instance.