/*@ Ox.VideoPlayer Generic Video Player (options, self) -> Video Player options Options annotation <[o]> Array of annotation tracks name Name of the annotation track data <[o]> Annotation data in In point (sec) out Out point (sec) text Text controls <[s]> Controls, from left to right Can be 'play', 'playInToOut', 'mute', 'volume', 'size', 'scale', 'timeline', 'space', 'position', 'settings'. The 'space' control is just empty space that separates left-aligned from right-aligned controls duration Duration (sec) enableKeyboard If true, enable keyboard controls externalControls If true, controls are outside the video focus focus on 'click', 'load' or 'mouseover' fps Frames per second height Height in px (excluding external controls) in In point (sec) keepIconVisible If true, play icon stays visible after mouseleave keepLargeTimelineVisible If true, large timeline stays visible after mouseleave keepLogoVisible If true, logo stays visible after mouseleave logo Logo image URL logoLink Logo link URL logoTitle Text for tooltip muted If true, video is muted paused If true, video is paused playInToOut If true, video plays only from in to out position Initial position (sec) poster Poster URL posterFrame Position of poster frame (sec) preload 'auto', 'metadata' or 'none' out Out point (sec) scaleToFill If true, scale to fill (otherwise, scale to fit) showControlsOnLoad If true, show controls on load showFind If true, show find input showHours If true, don't show hours for videos shorter than one hour showIcon If true, show play icon showIconOnLoad If true, show icon on load showLargeTimeline If true, show large timeline showMilliseconds If true, show milliseconds showPointMarkers If true, show in/out markers sizeIsLarge If true, initial state of the size control is large subtitles URL or SRT or array of subtitles in In point (sec) out Out point (sec) text Text timeline Timeline image URL title Video title type 'play', 'in' or 'out' video Video URL volume Volume (0-1) width Width in px @*/ Ox.VideoPlayer = function(options, self) { self = self || {}; var that = Ox.Element({}, self) .defaults({ annotations: [], controls: [], duration: -1, enableKeyboard: false, externalControls: false, focus: 'click', fps: 25, height: 144, 'in': -1, keepIconVisible: false, keepLargeTimelineVisible: false, keepLogoVisible: false, logo: '', logoLink: '', logoTitle: '', muted: false, paused: false, playInToOut: false, position: 0, poster: '', preload: 'auto', out: -1, scaleToFill: false, showControlsOnLoad: false, showFind: false, showHours: false, showIcon: false, showIconOnLoad: false, showLargeTimeline: false, showMilliseconds: false, showPointMarkers: false, subtitles: [], timeline: '', title: '', type: 'play', video: '', volume: 1, width: 256 }) .options(options || {}) .css({ position: 'absolute' }); if (self.options.controls.length || self.options.showIcon || self.options.title) { that.bind({ mouseenter: showInterface, mouseleave: hideInterface }); } if (Ox.isString(self.options.subtitles)) { if (self.options.subtitles.indexOf('\n') > -1) { self.options.subtitles = Ox.parseSRT(self.options.subtitles); } else { Ox.get(self.options.subtitles, function(data) { self.options.subtitles = Ox.parseSRT(data); }); //self.options.subtitles = []; } } // fixme: this is _relative_, resizing can happen self.ratio = self.options.width / self.options.height; self.barHeight = 16; setSize(); self.millisecondsPerFrame = 1000 / self.options.fps; self.buffered = []; self.controlsTimeout; self.dragTimeout; self.$videoContainer = $('
') .css({ position: 'absolute', width: self.options.width + 'px', height: self.options.height + 'px', overflow: 'hidden' }) .appendTo(that.$element) self.$video = $('