sortSources = (sources) -> if not sources console.error('sortSources() called with null source list') return [] qualities = ['1080', '720', '480', '360', '240'] pref = String(USEROPTS.default_quality) idx = qualities.indexOf(pref) if idx < 0 idx = 2 qualityOrder = qualities.slice(idx).concat(qualities.slice(0, idx).reverse()) sourceOrder = [] flvOrder = [] for quality in qualityOrder if quality of sources flv = [] nonflv = [] sources[quality].forEach((source) -> source.quality = quality if source.contentType == 'video/flv' flv.push(source) else nonflv.push(source) ) sourceOrder = sourceOrder.concat(nonflv) flvOrder = flvOrder.concat(flv) return sourceOrder.concat(flvOrder).map((source) -> type: source.contentType src: source.link quality: source.quality ) waitUntilDefined(window, 'videojs', => videojs.options.flash.swf = '/video-js.swf' ) window.VideoJSPlayer = class VideoJSPlayer extends Player constructor: (data) -> if not (this instanceof VideoJSPlayer) return new VideoJSPlayer(data) @setMediaProperties(data) @loadPlayer(data) loadPlayer: (data) -> waitUntilDefined(window, 'videojs', => video = $('