"use strict"; var granicusPlayer = (function() { var loadedPlayers = {}; var root = function(target,options) { if(loadedPlayers[target]) { return loadedPlayers[target]; } var api = {}; var parent = document.getElementById(target); var iframe = document.createElement('IFRAME'); api.time = 0; options.autoplay = options.autoplay ? 1 : 0; parent = document.getElementById(target); iframe = document.createElement('IFRAME'); if(options.stream) { iframe.src = "//floor.senate.gov/livestreams/" + options.stream + "/player?autoplay="+ options.autoplay; } if(options.video) { iframe.src = "//floor.senate.gov/videos/" + options.video + "/player?autoplay="+ options.autoplay; if(options.start) { iframe.src += '&start=' + options.start; } if(options.stop) { iframe.src += '&stop=' + options.stop; } if(options.seek) { iframe.src += '&t=' + options.seek; } } if(options.disableCaptions) { iframe.src += '&captions=false'; } if(options.splashImage) { iframe.src += '&splash=' + options.splashImage; } if(options.disableFullScreen) { iframe.src += '&disableFullScreen=' + options.disableFullScreen; } if (options.volume == 0) { options.volume = '0.0'; } if (options.volume >=0) { iframe.src += '&volume=' + options.volume; } iframe.width = options.width || '100%'; iframe.height = options.height || '100%'; iframe.setAttribute('allowFullScreen', ''); iframe.setAttribute('mozallowfullscreen', ''); iframe.setAttribute('webkitallowfullscreen', ''); iframe.frameBorder = 0; parent.appendChild(iframe); window.addEventListener("message", function (event) { if(event.origin !== "http://floor.senate.gov" && event.origin !== "https://floor.senate.gov") { return; } if(event.data && event.data.time) { api.time = event.data.time; } }); api.play = function() { iframe.contentWindow['postMessage']({ command: "play"}, '*'); } api.pause = function() { iframe.contentWindow['postMessage']({ command: "pause"}, '*'); } api.stop = function() { iframe.contentWindow['postMessage']({ command: "stop"}, '*'); } api.seek = function(time) { iframe.contentWindow['postMessage']({ command: "seek", time: time }, '*'); } loadedPlayers[target] = api; return api; }; root.init = root; return root; }());