Genuin Audio - Video Dynamic SDK
Integrate Genuin Audio-Video dynamic SDK on a phrase click, with the sponsor’s read and audio ads built in, or open it in your own popover. Both previews are live: switch the size at the top and the code switches with it.
Add the script
Once per page, just before </body>.
<script async src="https://media.begenuin.com/cxr/2.0.0/gen_ext.min.js"></script>
Place the Genuin Audio Video Dynamic SDK with either of these
In-text popover
Wrap a phrase in a span. Tapping it opens Genuin’s Audio Video Dynamic SDK over your article.
<span class="gen-ext-highlighted" data-tag-id="{{TAG}}"
data-popover-width="{{W}}" data-popover-height="{{H}}">Sony’s new gear</span>
data-popover-width and data-popover-height are optional: they set the popover
size.
Iframe popover
Show the widget in your own popover, inside an iframe. Add ?cxrEmbed=popover to the script URL
and the widget’s ⌄ minimize, ✕ close and expand buttons send your page a message:
cxr:hidehides the popover (close: truemeans remove the iframe).cxr:expandmakes the popover full window, or shrinks it back.cxr:resizechanges the iframe height.
<span id="my-keyword" role="button" tabindex="0">this week’s picks</span>
<div id="my-popover" style="position:absolute;z-index:1000" hidden></div>
<script>
var keyword = document.getElementById("my-keyword");
var popover = document.getElementById("my-popover");
var frame = null;
// The page inside the iframe: one widget + the Genuin script in popover mode.
var WIDGET_PAGE =
'<style>html,body{margin:0;height:100%;overflow:hidden}' +
'.gen-ext{display:block;width:100vw;height:100vh}</style>' +
'<div class="gen-ext" data-tag-id="{{TAG}}"></div>' +
'<script async src="https://media.begenuin.com/cxr/2.0.0/gen_ext.min.js?cxrEmbed=popover"><\/script>';
function open() {
if (!frame) {
frame = document.createElement("iframe");
frame.allow = "autoplay; fullscreen";
frame.style.cssText = "display:block;border:0;width:{{W}}px;height:{{H}}px";
frame.srcdoc = WIDGET_PAGE;
popover.appendChild(frame);
}
place();
popover.hidden = false;
}
// Just under the keyword.
function place() {
var rect = keyword.getBoundingClientRect();
popover.style.left = rect.left + window.scrollX + "px";
popover.style.top = rect.bottom + 10 + window.scrollY + "px";
}
function close() {
popover.innerHTML = ""; // removing the iframe stops the widget
frame = null;
popover.hidden = true;
}
// Messages from the widget's buttons.
window.addEventListener("message", function (e) {
if (!frame || e.source !== frame.contentWindow) return;
if (e.data.type === "cxr:hide") {
if (e.data.close) close();
else popover.hidden = true; // minimized: keeps playing
}
if (e.data.type === "cxr:expand") {
var full = e.data.expanded;
popover.style.position = full ? "fixed" : "absolute";
popover.style.inset = full ? "0" : "";
frame.style.width = full ? "100%" : "{{W}}px";
frame.style.height = full ? "100%" : "{{H}}px";
if (!full) place();
}
if (e.data.type === "cxr:resize") frame.style.height = (e.data.height || {{H}}) + "px";
});
keyword.addEventListener("click", function () {
popover.hidden ? open() : close();
});
</script>
Good to know
- The popover can be 600, 250, 100 or 50 tall: set
data-popover-heightand the player picks its layout. - Add the script only once, and have your Genuin elements in the page HTML when it loads.
- Videos start muted; browsers only allow sound after the visitor taps.