##dz-db-collector-details
Plugin Integration
Datazoom provides plugins for data collection through our Beacon Services. Integrate the AWS IVS Player plugin into your web application with the following snippet:
<script src='https://platform.datazoom.io/beacon/v1/config?configuration_id=CONFIG_ID'></script>
Insert this line into your HTML
Replace the
CONFIG_ID
value with Collector configuration id.
This inserts Datazoom's data collection SDK into the page.
Include the following tag (for the latest version of the AWS IVS player).
<script src="https://player.live-video.net/1.21.0/amazon-ivs-player.min.js"></script>
Activate Data Collection for an AWS IVS Player
To activate data collection for an AWS IVS Player instance, create a Datazoom context which references the player instance with the following snippet:
datazoom_context = datazoom.createContext(aws_ivs_player);
For example:
<!DOCTYPE html> <html lang="en"> <head> <!-- THE AWS IVS SCRIPT --> <script src="https://player.live-video.net/1.16.0/amazon-ivs-player.min.js"></script> <!-- THE DATAZOOM BEACON SCRIPT --> <script src='https://platform.datazoom.io/beacon/v1/config?configuration_id=CONFIG_ID'></script> </head> <body> <!-- THE VIDEO PLAYER --> <div> <video id="video" style="width:50%;height:50%" controls></video> </div> <script> var aws_ivs_player; var datazoom_context; var url = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"; // Create a Player instance if (IVSPlayer.isPlayerSupported) { aws_ivs_player = IVSPlayer.create(); aws_ivs_player.attachHTMLVideoElement(document.getElementById("video")); aws_ivs_player.load(url); // Activates data collection datazoom_context = datazoom.createContext(aws_ivs_player); } </script> </body> </html>
Stop Data Collection
If the data collection must be stopped for any reason, for example after the destruction of the corresponding player instance, invoke the destroy()
method of the Datazoom context object as in the following example:
if (aws_ivs_player) { aws_ivs_player.delete(); aws_ivs_player = null; } if (datazoom_context) { datazoom_context.destroy(); datazoom_context = null; }
NPM (Node Package Manager)
We have made it convenient to manage your Amazon IVS Collector integration by providing NPM (Node Package Manager) support. Please see installation details here.
References:
Amazon IVS Web Player SDK Reference
Additional Examples
IVS plugin (tech) through a videojs player
<!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.14.3/video-js.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.14.3/video.min.js"></script> <script src="https://player.live-video.net/1.4.0/amazon-ivs-videojs-tech.min.js"></script> <script src='https://platform.datazoom.io/beacon/v1/config?configuration_id=<CONFIG_ID>'></script> </head> <body> <div> <div id="video-container" style="width:50%"> <video id="video" class="video-js vjs-16-9 vjs-big-play-centered" controls></video> </div> <hr/> <button id="src_bunny">Bunny</button> <button id="src_bipbop">BipBop</button> <br/> <input id="src" type="text" style="width:80%"></input> <hr/> <button id="create">Create</button> <button id="destroy">Destroy</button> </div> <script> registerIVSTech(videojs); // Register Amazon IVS as playback technology for Video.js var vjs_player; var datazoom_context; var elSource = document.getElementById("src"); function setSourceURL(url) { elSource.value = url; } document.getElementById("src_bunny").onclick = function() { setSourceURL("https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"); }; document.getElementById("src_bipbop").onclick = function() { setSourceURL("https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8"); }; document.getElementById("create").onclick = function() { var url = elSource.value; if (!url) { alert("Error: source URL is empty"); return; } vjs_player = videojs("video", { techOrder: [ "AmazonIVS" ] }, function() { datazoom_context = datazoom.createContext(vjs_player.getIVSPlayer()); vjs_player.src(url); }); }; document.getElementById("destroy").onclick = function() { if (vjs_player) { vjs_player.dispose(); vjs_player = null; } if (datazoom_context) { datazoom_context.destroy(); datazoom_context = null; } }; </script> </body> </html>
IVS plugin (tech) through JW Player
<!DOCTYPE html> <html lang="en"> <head> <script src="https://content.jwplatform.com/libraries/<your.js>"></script> <script src="https://player.live-video.net/1.4.0/amazon-ivs-jw-provider.min.js"></script> <script src='https://platform.datazoom.io/beacon/v1/config?configuration_id=<CONFIG_ID>'></script> </head> <body> <div> <div id="video" style="width:50%"></div> <hr/> <button id="src_bunny">Bunny</button> <button id="src_bipbop">BipBop</button> <br/> <input id="src" type="text" style="width:80%"></input> <hr/> <button id="create">Create</button> <button id="destroy">Destroy</button> </div> <script> var jw_player; var datazoom_context; var elSource = document.getElementById("src"); function setSourceURL(url) { elSource.value = url; } document.getElementById("src_bunny").onclick = function() { setSourceURL("https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"); }; document.getElementById("src_bipbop").onclick = function() { setSourceURL("https://devstreaming-cdn.apple.com/videos/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8"); }; document.getElementById("create").onclick = function() { var url = elSource.value; if (!url) { alert("Error: source URL is empty"); return; } var config = { playlist: [{ file: url, type: "ivs" }], width: 640, height: 360 }; jw_player = jwplayer("video").setup(config); jw_player.on("providerPlayer", function(providerPlayer) { datazoom_context = datazoom.createContext(providerPlayer.ivsPlayer); }); }; document.getElementById("destroy").onclick = function() { if (jw_player) { jw_player.remove(); jw_player = null; } if (datazoom_context) { datazoom_context.destroy(); datazoom_context = null; } }; </script> </body> </html>
Comments
0 comments
Article is closed for comments.