(function() { var Player, TYPE_MAP, VideoJSPlayer, YouTubePlayer, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; Player = (function() { function Player(data) { this.setMediaProperties(data); this.paused = false; } Player.prototype.load = function(data) { return this.setMediaProperties(data); }; Player.prototype.setMediaProperties = function(data) { this.mediaId = data.id; this.mediaType = data.type; return this.mediaLength = data.seconds; }; Player.prototype.play = function() { return this.paused = false; }; Player.prototype.pause = function() { return this.paused = true; }; Player.prototype.seekTo = function(time) {}; Player.prototype.setVolume = function(volume) {}; Player.prototype.getTime = function(cb) { return cb(0); }; Player.prototype.isPaused = function(cb) { return cb(this.paused); }; Player.prototype.getVolume = function(cb) { return cb(VOLUME); }; return Player; })(); window.Player = Player; window.removeOld = function(replace) { var old; $('#sc_volume').remove(); if (replace == null) { replace = $('
').addClass('embed-responsive-item'); } old = $('#ytapiplayer'); replace.insertBefore(old); old.remove(); replace.attr('id', 'ytapiplayer'); return replace; }; TYPE_MAP = { yt: 'YouTubePlayer' }; window.loadMediaPlayer = function(data) { var ctor; if (data.type in TYPE_MAP) { ctor = window[TYPE_MAP[data.type]]; return window.PLAYER = new ctor(data); } }; window.handleMediaUpdate = function(data) { var PLAYER, waiting; PLAYER = window.PLAYER; if (typeof PLAYER.mediaLength === 'number' && PLAYER.mediaLength > 0 && data.currentTime > PLAYER.mediaLength) { return; } waiting = data.currentTime < 0; if (data.id && data.id !== PLAYER.mediaId) { if (data.currentTime < 0) { data.currentTime = 0; } PLAYER.load(data); PLAYER.play(); } if (waiting) { console.log('waiting'); if (PLAYER.type === 'yt') { PLAYER.pauseSeekRaceCondition = true; } else { PLAYER.seekTo(0); PLAYER.pause(); } } else if (PLAYER.type === 'yt') { PLAYER.pauseSeekRaceCondition = false; } if (CLIENT.leader || !USEROPTS.synch) { return; } if (data.paused && !PLAYER.paused) { PLAYER.seekTo(data.currentTime); PLAYER.pause(); } else if (PLAYER.paused) { PLAYER.play(); } return PLAYER.getTime(function(seconds) { var accuracy, diff, time; time = data.currentTime; diff = (time - seconds) || time; accuracy = USEROPTS.sync_accuracy; if (PLAYER.type === 'dm') { accuracy = Math.max(accuracy, 5); } if (diff > accuracy) { return PLAYER.seekTo(time); } else if (diff < -accuracy) { if (PLAYER.type !== 'dm') { time += 1; } return PLAYER.seekTo(time); } }); }; VideoJSPlayer = (function(superClass) { extend(VideoJSPlayer, superClass); function VideoJSPlayer(data) {} VideoJSPlayer.prototype.load = function(data) { var video; return video = $('