Embedding via JavaScript

The most advanced and flexible way to embed the player is through our JavaScript library. With it, you can control the player instance, listen to events, and integrate with other functionalities of your application.

1. Include the script
<script src="https://iplayerplus.com/embed.js"></script>
2. Create the player container
<div id="player-container"></div>
3. Instantiate the player via JavaScript
new Player({
	ivideo_id: ':video_id',
	target: '#player-container',
	access_key: 'key',
});

Some optional parameters can be passed in the player instance:

Optional parameters:
  • width:  Player width in pixels.
  • height:  Player height in pixels.
  • autoplay:  Automatically play the video.
  • content:  A JSON with user data who will watch the video.
    Example: {"user_id":"1","name":"Lucas"}
  • onReady:  Callback executed when the player is ready.
  • onStateChange(state:string):  Callback executed when the player's state changes. The available states are:playing,paused,ended

This approach is ideal for scenarios where you need full control over the player, such as custom event logging, programmatic navigation, and integration with gamification systems or dashboards.