/* soundcite - v0.5.1 - 2017-07-10 * Copyright (c) 2017 Tyler J. Fisher and Northwestern University Knight Lab */ (function(window,document,callback){var loaded_p=true;var loaded_s=true;var insertionPoint=document.head||document.getElementsByTagName("head").item(0)||document.documentElement.childNodes[0];function cmp_vers(v1,v2){var a1=v1.split(".");var a2=v2.split(".");for(var i=0;i0||cb(js)){var script=document.createElement("script");script.type="text/javascript";script.src="https://cdn.knightlab.com/libs/soundcite/latest/vendor/popcorn.min.js";script.onload=script.onreadystatechange=function(){if(!loaded_p&&(!(d=this.readyState)||d=="loaded"||d=="complete")){new_js=window.Popcorn;if(js){window.Popcorn=js}cb(new_js,loaded_p=true);insertionPoint.removeChild(script)}};insertionPoint.appendChild(script)}}function load_soundcloud(version,cb){var js=window.SC,d;if(loaded_s){cb(js)}else if(!js||!js.Dialog||cmp_vers(version,js._version)>0||cb(js)){var script=document.createElement("script");script.type="text/javascript";script.src="//connect.soundcloud.com/sdk-2.0.0.js";script.onload=script.onreadystatechange=function(){if(!loaded_s&&(!(d=this.readyState)||d=="loaded"||d=="complete")){cb(window.SC,loaded_s=true);insertionPoint.removeChild(script)}};insertionPoint.appendChild(script)}}function r(f){if(/in/.test(document.readyState)){setTimeout(function(){r(f)},9)}else{f()}}r(function(){var elements=document.getElementsByClassName("soundcite");for(var i=0;i=0&&i<=255}if(rgb&&valid_color(rgb[0])&&valid_color(rgb[1])&&valid_color(rgb[2])){return rgb}return null}var update_playing_element=function(el,percentage){var color=SOUNDCITE_CONFIG.background_color||"0,0,0";el.style.cssText="background: -webkit-linear-gradient(left, rgba("+color+",.15)"+percentage+"%, rgba("+color+",.05)"+(percentage+1)+"%);"+"background: linear-gradient(to right, rgba("+color+",.15)"+percentage+"%, rgba("+color+",.05)"+(percentage+1)+"%);"};window.soundcite={};if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){soundcite.mobile=true}else{soundcite.mobile=false}var clips=[];var audio_container=document.createElement("div");addClass(audio_container,"soundcite-audio");document.getElementsByTagName("body")[0].appendChild(audio_container);if($SoundCloud){$SoundCloud.initialize({client_id:SOUNDCITE_CONFIG["soundcloud_client_id"]})}function pause_all_clips(except_clip){for(var i=0;i=this.end){if(this.plays){this.plays_left--;if(this.plays_left>0){this.play();this.track_position()}else{this.stop()}}else{this.play();this.track_position()}}},this));if(this.end===null){this.end=this.sound.getDuration()}this.sound_loaded()},this))}SoundCloudClip.prototype=Object.create(Clip.prototype);SoundCloudClip.prototype.sound_position=function(){return this.sound.getCurrentPosition()};SoundCloudClip.prototype.pause_sound=function(){this.sound.pause()};SoundCloudClip.prototype.stop_sound=function(){this.sound.stop()};SoundCloudClip.prototype.play=function(){var pos=this.sound_position();if(pos=this.end){this.sound.seek(this.start)}removeClass(this.el,"soundcite-play");addClass(this.el,"soundcite-pause");this.sound.play();this.playing=true};function PopcornClip(el){Clip.apply(this,Array.prototype.slice.call(arguments));this.id="soundcite-audio-"+clips.length;this.url=el.getAttribute("data-url");this.start=Math.floor(this.start/1e3);if(this.end!==null){this.end=Math.floor(this.end/1e3)}var audio=document.createElement("audio");audio.id=this.id;audio.setAttribute("src",this.url);audio.setAttribute("preload","true");audio_container.appendChild(audio);this.sound=$Popcorn("#"+this.id,{frameAnimation:true});this.sound.on("loadeddata",bind(function(){if(this.end===null){this.end=this.sound.duration()}this.sound.cue(this.end,bind(function(){if(this.plays){this.plays_left--;if(this.plays_left>0){this.sound.currentTime(this.start);this.play()}else{this.stop();this.sound.currentTime(this.start)}}else{this.sound.currentTime(this.start);this.play()}},this));if(!soundcite.mobile){this.sound_loaded()}},this));if(soundcite.mobile){this.sound_loaded()}else if(this.sound.readyState()>1){this.sound_loaded()}}PopcornClip.prototype=Object.create(Clip.prototype);PopcornClip.prototype.sound_position=function(){return this.sound.currentTime()};PopcornClip.prototype.pause_sound=function(){this.sound.pause();this.sound.off("timeupdate")};PopcornClip.prototype.stop_sound=function(){this.sound.pause();this.sound.off("timeupdate")};PopcornClip.prototype._play_sound=function(){removeClass(this.el,"soundcite-loading soundcite-play");addClass(this.el,"soundcite-pause");this.sound.play();this.playing=true;this.sound.on("timeupdate",bind(this.track_progress,this))};PopcornClip.prototype.play_sound=function(){var pos=this.sound.roundTime();if(pos=this.end){this.sound.on("seeked",bind(function(){this.sound.off("seeked");this._play_sound()},this));this.sound.currentTime(this.start)}else{this._play_sound()}};PopcornClip.prototype.play=function(){if(soundcite.mobile){removeClass(this.el,"soundcite-play");addClass(this.el,"soundcite-loading");if(this.sound.readyState()>1){this.play_sound()}else{this.sound.on("canplaythrough",bind(function(){this.play_sound()},this));document.getElementById(this.id).load()}}else{this.play_sound()}};for(var i=0;i