diff --git a/samples/advanced/listening-to-SCTE-EMSG-events.html b/samples/advanced/listening-to-SCTE-EMSG-events.html index f30d3e4522..67ad5431a2 100644 --- a/samples/advanced/listening-to-SCTE-EMSG-events.html +++ b/samples/advanced/listening-to-SCTE-EMSG-events.html @@ -13,35 +13,46 @@ var player; const URL = "https://livesim.dashif.org/livesim/scte35_2/testpic_2s/Manifest.mpd"; const SCHEMEIDURI = "urn:scte:scte35:2013:xml"; + const EVENT_MODE_ON_START = dashjs.MediaPlayer.events.EVENT_MODE_ON_START; + const EVENT_MODE_ON_RECEIVE = dashjs.MediaPlayer.events.EVENT_MODE_ON_RECEIVE; function init() { player = dashjs.MediaPlayer().create(); player.updateSettings({ 'debug': { 'logLevel': dashjs.Debug.LOG_LEVEL_NONE }}); - player.on(SCHEMEIDURI, showEvent); + player.on(SCHEMEIDURI, showStartEvent, null); /* Default mode is onStart, no need to specify a mode */ + player.on(SCHEMEIDURI, showReceiveEvent, null, { mode: EVENT_MODE_ON_RECEIVE }); player.initialize(document.querySelector("video"), URL, true); } - function showEvent(e) { - log("EVENT RECEIVED: " + e.type); + function showStartEvent(e) { + showEvent(e, "start"); + } + + function showReceiveEvent(e) { + showEvent(e, "receive"); + } + + function showEvent(e, output) { /* We double process in order to pretty-print. Only two levels of object properties are exposed. */ for (var name in e) { if (typeof e[name] != 'object') { - log(" " + name + ": " + e[name]); + log(" " + name + ": " + e[name], output); } } for (name in e) { if (typeof e[name] == 'object' ) { - log(" " + name + ":"); + log(" " + name + ":", output); for (name2 in e[name]) { - log(" " + name2 + ": " + JSON.stringify(e[name][name2])); + log(" " + name2 + ": " + JSON.stringify(e[name][name2]), output); } } } + log("", output); } - function log(msg) { + function log(msg, output) { msg = msg.length > 200 ? msg.substring(0, 200) + "..." : msg; /* to avoid repeated wrapping with large objects */ - var tracePanel = document.getElementById("trace"); + var tracePanel = document.getElementById(output); tracePanel.innerHTML += msg + "\n"; tracePanel.scrollTop = tracePanel.scrollHeight; console.log(msg); @@ -68,7 +79,16 @@
Received Events
+ +Started Events
+ +