diff -r 919e362b9db1 -r 3ab36f402b0c src/widgets/PopcornPlayer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/widgets/PopcornPlayer.js Thu Jan 02 16:40:25 2014 +0100 @@ -0,0 +1,138 @@ +IriSP.Widgets.PopcornPlayer = function(player, config) { + IriSP.Widgets.Widget.call(this, player, config); +}; + +IriSP.Widgets.PopcornPlayer.prototype = new IriSP.Widgets.Widget(); + +/* A Popcorn-based player for HTML5 Video, Youtube and Vimeo */ + +IriSP.Widgets.PopcornPlayer.prototype.defaults = { +}; + +IriSP.Widgets.PopcornPlayer.prototype.draw = function() { + + + if (typeof this.video === "undefined") { + this.video = this.media.video; + } + + if (this.url_transform) { + this.video = this.url_transform(this.video); + } + + if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) { + + /* VIMEO */ + + var _popcorn = Popcorn.vimeo(this.container, this.video); + + } else if (/^(https?:\/\/)?(www\.)?youtube\.com/.test(this.video)) { + + /* YOUTUBE */ + + var _urlparts = this.video.split(/[?&]/), + _params = {}; + for (var i = 1; i < _urlparts.length; i++) { + var _ppart = _urlparts[i].split('='); + _params[_ppart[0]] = decodeURIComponent(_ppart[1]); + } + _params.controls = 0; + _params.modestbranding = 1; + if (this.autostart || this.autoplay) { + _params.autoplay = 1; + } + _url = _urlparts[0] + '?' + IriSP.jQuery.param(_params); + + var _popcorn = Popcorn.youtube(this.container, _url); + + } else { + + /* DEFAULT HTML5 */ + + var _tmpId = IriSP._.uniqueId("popcorn"), + _videoEl = IriSP.jQuery('