src/widgets/PopcornPlayer.js
changeset 987 7b65bf78873a
parent 979 ff62016e051d
child 1013 392ddcd212d7
equal deleted inserted replaced
986:f9d51dd4a3fe 987:7b65bf78873a
     5 IriSP.Widgets.PopcornPlayer.prototype = new IriSP.Widgets.Widget();
     5 IriSP.Widgets.PopcornPlayer.prototype = new IriSP.Widgets.Widget();
     6 
     6 
     7 /* A Popcorn-based player for HTML5 Video, Youtube and Vimeo */
     7 /* A Popcorn-based player for HTML5 Video, Youtube and Vimeo */
     8 
     8 
     9 IriSP.Widgets.PopcornPlayer.prototype.defaults = {
     9 IriSP.Widgets.PopcornPlayer.prototype.defaults = {
    10     aspect_ratio: 14/9
       
    11 }
    10 }
    12 
    11 
    13 IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
    12 IriSP.Widgets.PopcornPlayer.prototype.draw = function() {
    14 
    13 
    15     
    14     
    17         this.video = this.media.video;
    16         this.video = this.media.video;
    18     }
    17     }
    19     
    18     
    20     if (this.url_transform) {
    19     if (this.url_transform) {
    21         this.video = this.url_transform(this.video);
    20         this.video = this.url_transform(this.video);
    22     }
       
    23     
       
    24     if (!this.height) {
       
    25         this.height = Math.floor(this.width/this.aspect_ratio);
       
    26         this.$.css({
       
    27                 height: this.height
       
    28             });
       
    29     }
    21     }
    30     
    22     
    31     if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) {
    23     if (/^(https?:\/\/)?(www\.)?vimeo\.com/.test(this.video)) {
    32         
    24         
    33         /* VIMEO */
    25         /* VIMEO */
    60         var _tmpId = IriSP._.uniqueId("popcorn"),
    52         var _tmpId = IriSP._.uniqueId("popcorn"),
    61             _videoEl = IriSP.jQuery('<video>');
    53             _videoEl = IriSP.jQuery('<video>');
    62         _videoEl.attr({
    54         _videoEl.attr({
    63             id : _tmpId,
    55             id : _tmpId,
    64             width : this.width,
    56             width : this.width,
    65             height : this.height
    57             height : this.height || undefined
    66         });
    58         });
    67         if(typeof this.video === "string"){
    59         if(typeof this.video === "string"){
    68             _videoEl.attr("src",this.video);
    60             _videoEl.attr("src",this.video);
    69         } else {
    61         } else {
    70             for (var i = 0; i < this.video.length; i++) {
    62             for (var i = 0; i < this.video.length; i++) {