The AnyClip embed code will load a JS file named lre.js. Once the lre.js file has finished loading on the page, player initialization will begin automatically. Once the initialization process is complete, the following processes will begin:
The player will fire a playerReady event with a Window.postMessage().
A new player will be added to the window.anyclip.widgets array.
The player will attempt to compile a playlist, load it, and begin playback.
playerReady Event
Upon successful player initialization, the player will fire a Window.postMessage() event called playerReady, which will be populated with a session ID that the newly created player has been given, in the following format:
lre:playerReady://<session ID>
Important
You can begin calling API functions on an AnyClip player only after the playerReady event for this particular widget has been fired.
For example:
lre:playerReady://lhfPJ9AO1zzZHYk7YSZasCqwNoAAdamr
Add the event listener for a “message” event in the window, to receive a newly created player session ID for further player reference.
For example:
var widget_1_sid = null;
window.addEventListener('message',
(event => {
if (event?.data && typeof event.data === 'string' && event.data.indexOf('lre:playerReady://') === 0)
{ widget_1_sid = JSON.parse(event.data.slice('lre:playerReady://'.length));
console.log("New LRE player created on page with session ID:" + widget_1_sid);
}
})
)