Player.js allows you to interface with the iframe using a set of standardized methods and events across a wide range of supported rich media players.
Read the player.js documentation to learn how to implement player.js on your website.
View demo code and example to see it working live.
The Omny Studio embed player emits the following player.js events
play - when the player is played
pause - when the player is paused
ended - when the player has finished playing the clip
timeupdate - while the player is playing, updates the current time in seconds and the duration in seconds
The Omny Studio embed player supports the following player.js methods
play() - play the player
pause() - pause the player
getPaused() - returns if the player is paused
setCurrentTime() - seeks to the time in seconds
getCurrentTime() - returns the current position in seconds
getDuration() - returns the duration in seconds
mute() - mutes the player
unmute() - unmutes the player
getMuted() - returns if the player is muted
getVolume() - returns the player's volume in %
setVolume() - sets the player's volume in %
iFrame autoplay policy
Due to recent Google Chrome's autoplay policy changes, programmatically playing the embed using player.js might be restricted by default.
You can workaround the behaviour by adding
allow="autoplay" to the iframe element which will delegate the play permission to the cross-domain iframe (assumes your site has autoplay permissions).
For example, your iframe code will look like
<iframe src="https://omny.fm/..." allow="autoplay"></iframe>
If your website includes a "Referrer-Policy", specifically a value of
Referrer-Policy: same-origin, then player.js might not work out of the box.
By default, for security reasons, the player.js library is designed to only send events to the parent window/document by specifying the
targetOrigin parameter. The
targetOrigin is assumed to be the
If the referrer policy
same-origin is specified, then the Omny.fm embed player and player.js cannot automatically determine which origin it should send messages to.
You can overcome this issue by specifying a
referrer URL parameter on the omny.fm embed player iframe URL with the domain of your website (including the protocol).
<iframe src="https://omny.fm/shows/breakfast-with-john/baltic-bumpers/embed?style=cover&referrer=https://example.com" allow="autoplay; clipboard-write" frameborder="0" width="100%" height="180"></iframe>